Example #1
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!");
        }
Example #2
0
        // t[k]=v
        void setTable(ref object t, object k, object v)
        {
            if (LuaValue.isLuaTable(t))
            {
                var tbl = LuaValue.toLuaTable(t);
                tbl.put(k, v);
                t = tbl;
                return;
            }

            throw new Exception("not a table!");
        }
Example #3
0
        void setTable(int idx, LuaValue k, LuaValue v)
        {
            var t = new LuaValue(stack.get(idx));

            if (t.isLuaTable())
            {
                var table = t.toLuaTable();
                table.put(k, v);
                stack.set(idx, table);
                return;
            }

            throw new Exception("not a table!");
        }
Example #4
0
        void setTable(int idx, object k, object v)
        {
            var t = stack.get(idx);

            if (LuaValue.isLuaTable(t))
            {
                var table = LuaValue.toLuaTable(t);
                table.put(k, v);
                stack.set(idx, table);
                return;
            }

            throw new Exception("not a table!");
        }
Example #5
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!");
        }
Example #6
0
        LuaType getTable(LuaValue t, LuaValue k)
        {
            if (t.isLuaTable())
            {
                var tbl = t.toLuaTable();
                var v   = tbl.get(k).value;
                if (v.GetType().IsEquivalentTo(typeof(LuaValue)))
                {
                    v = ((LuaValue)v).value;
                }

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

            throw new Exception("not a table!");
        }
Example #7
0
        public void Len(int idx)
        {
            var val = stack.get(idx);

            if (LuaValue.isString(val))
            {
                var s = LuaValue.toString(val);
                stack.push((long)s.Length);
            }
            else if (LuaValue.isLuaTable(val))
            {
                var t = LuaValue.toLuaTable(val);
                stack.push((long)t.len());
            }
            else
            {
                throw new Exception("length error!");
            }
        }