示例#1
0
文件: Lua.cs 项目: yarligayan/libTech
        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);
            }
        }
示例#2
0
文件: Lua.cs 项目: yarligayan/libTech
        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);
        }
示例#3
0
文件: Lua.cs 项目: yarligayan/libTech
        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);
        }
示例#4
0
文件: Lua.cs 项目: yarligayan/libTech
        public static LuaReference ConvertToTable <T>(T Obj) where T : struct
        {
            Type ObjType = Obj.GetType();

            FieldInfo[] Fields = ObjType.GetFields();

            LL.lua_newtable(L);

            for (int i = 0; i < Fields.Length; i++)
            {
                Advanced.Push(L, Fields[i].GetValue(Obj));
                LL.lua_setfield(L, -2, Fields[i].Name);
            }

            return(new LuaReference(L));
        }