コード例 #1
0
        public LuaType Type(int idx)
        {
            if (!stack.isValid(idx))
            {
                return(Consts.LUA_TNONE);
            }
            var val = stack.get(idx);

            return(LuaValue.typeOf(val));
        }
コード例 #2
0
        LuaType getTable(object t, object k)
        {
            if (LuaValue.isLuaTable(t))
            {
                var tbl = LuaValue.toLuaTable(t);
                var v   = tbl.get(k);
                stack.push(v);
                return(LuaValue.typeOf(v));
            }

            throw new Exception("not a table!");
        }
コード例 #3
0
        LuaType getTable(object t, object k)
        {
            if (LuaValue.isLuaTable(t))
            {
                var tbl = LuaValue.toLuaTable(t);
                var v   = tbl.get(k);
                if (v.GetType().IsEquivalentTo(typeof(LuaValue)))
                {
                    v = ((LuaValue)v);
                }

                stack.push(v);
                return(LuaValue.typeOf(v));
            }

            throw new Exception("not a table!");
        }
コード例 #4
0
ファイル: ApiGet.cs プロジェクト: 583004700/IdeaProjects
        LuaType getTable(object t, object k, bool raw)
        {
            if (t is LuaTable luaTable)
            {
                var v = luaTable.get(k);
                if (raw || v != null || !luaTable.hasMetafield("__index"))
                {
                    stack.push(v);
                    return(LuaValue.typeOf(v));
                }
            }

            if (!raw)
            {
                var mf = getMetafield(t, "__index", this);
                if (mf != null)
                {
                    switch (mf)
                    {
                    case LuaTable mfTable:
                        getTable(mfTable, k, false);
                        break;

                    case Closure closure:
                        stack.push(closure);
                        stack.push(t);
                        stack.push(k);
                        Call(2, 1);
                        var v = stack.get(-1);
                        return(LuaValue.typeOf(v));
                    }
                }
            }

            throw new Exception("not a table!");
        }