static void CopyTable() { int Idx = LL.lua_gettop(L); LL.lua_newtable(L); LL.lua_pushnil(L); while (LL.lua_next(L, Idx) != 0) { LL.lua_pushvalue(L, -2); LL.lua_insert(L, -2); LL.lua_settable(L, -4); } }
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)); }
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); }