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); } }
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); }
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); }
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)); }