diff --git a/Game.Shared/GarrysMod/LuaEntity.cs b/Game.Shared/GarrysMod/LuaEntity.cs index 0c59c30a..edde9063 100644 --- a/Game.Shared/GarrysMod/LuaEntity.cs +++ b/Game.Shared/GarrysMod/LuaEntity.cs @@ -1808,11 +1808,7 @@ static int Entity__EntIndex(ILuaInterface lua) { [LuaMethod] static int Entity__GetTable(ILuaInterface lua) { - LuaType type = lua.GetType(1); - if (type != LuaType.Entity && type != LuaType.Nil) - lua.TypeError("Entity", 1); - - BaseEntity? ent = UserGet(1); + BaseEntity? ent = Get_Entity(1, true); if (ent == null) return 0; @@ -1824,6 +1820,20 @@ static int Entity__GetTable(ILuaInterface lua) { return 1; } + [LuaMethod] + static int Entity__SetTable(ILuaInterface lua) { + BaseEntity ent = Get_Entity(1, false)!; + if (g_Lua!.GetType(2) != LuaType.Table) { + g_Lua.TypeError("table", 2); + return 0; + } + + ILuaObject? table = g_Lua.GetObject(2); + if (table != null) + ent.SetLuaTable(table); + return 0; + } + [LuaMethod] static int Entity____newindex(ILuaInterface lua) { BaseEntity? ent = Get_Entity(1, true);