Esempio n. 1
0
 public static void SetEnvironment(LuaFuncRef Func, LuaReference Env)
 {
     Func.GetRef();
     Env.GetRef();
     LL.lua_setfenv(L, -2);
     LL.lua_pop(L, 1);
 }
Esempio n. 2
0
        public static void SetTable <T>(LuaReference Table, string Name, T Obj) where T : struct
        {
            Table.GetRef();

            using (LuaReference Tbl = ConvertToTable(Obj)) {
                Tbl.GetRef();
                LL.lua_setfield(L, -2, Name);
            }
        }
Esempio n. 3
0
        public static T Get <T>(LuaReference Table, string Name)
        {
            int Top = GetTop();

            Table.GetRef();
            LL.lua_getfield(L, -1, Name);
            T Val = (T)Advanced.Get(L, 1, typeof(T));

            SetTop(Top);
            return(Val);
        }
Esempio n. 4
0
        public static void Copy(LuaReference TableFrom, LuaReference TableTo, string FromName, string ToName = null)
        {
            if (ToName == null)
            {
                ToName = FromName;
            }

            TableTo.GetRef();

            TableFrom.GetRef();
            LL.lua_getfield(L, -1, FromName);

            LL.lua_setfield(L, -3, ToName);
            LL.lua_pop(L, 2);
        }
Esempio n. 5
0
        public static void Set(LuaReference Table, string Name, object Obj)
        {
            Table.GetRef();

            if (Obj is LuaReference Ref)
            {
                Ref.GetRef();
            }
            else
            {
                Advanced.Push(L, Obj);
            }

            LL.lua_setfield(L, -2, Name);
            LL.lua_pop(L, 1);
        }
Esempio n. 6
0
        public static LuaReference CreateNewEnvironment(LuaReference OldEnvironment = null)
        {
            if (OldEnvironment != null)
            {
                OldEnvironment.GetRef();
                CopyTable();
            }
            else
            {
                LL.lua_newtable(L);
            }

            LuaReference Ref = new LuaReference(L);

            if (OldEnvironment != null)
            {
                LL.lua_pop(L, 1);
            }

            return(Ref);
        }