From 2239b9addfe96c12bc03814e8bd58ede9fbfd3c7 Mon Sep 17 00:00:00 2001 From: march <106459595+marchc1@users.noreply.github.com> Date: Fri, 16 Oct 2026 17:42:08 -0700 Subject: [PATCH] Add Entity:SetTable, fix GetTable expectation GetTable allows NULL and just returns nothing if given NULL it seems. --- Game.Shared/GarrysMod/LuaEntity.cs | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) 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);