Skip to content

Commit 0fa507e

Browse files
authored
Merge pull request #206 from marchc1/entity-settable
Add Entity:SetTable, fix GetTable expectation
2 parents 9949e60 + 2239b9a commit 0fa507e

1 file changed

Lines changed: 15 additions & 5 deletions

File tree

‎Game.Shared/GarrysMod/LuaEntity.cs‎

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1808,11 +1808,7 @@ static int Entity__EntIndex(ILuaInterface lua) {
18081808

18091809
[LuaMethod]
18101810
static int Entity__GetTable(ILuaInterface lua) {
1811-
LuaType type = lua.GetType(1);
1812-
if (type != LuaType.Entity && type != LuaType.Nil)
1813-
lua.TypeError("Entity", 1);
1814-
1815-
BaseEntity? ent = UserGet(1);
1811+
BaseEntity? ent = Get_Entity(1, true);
18161812
if (ent == null)
18171813
return 0;
18181814

@@ -1824,6 +1820,20 @@ static int Entity__GetTable(ILuaInterface lua) {
18241820
return 1;
18251821
}
18261822

1823+
[LuaMethod]
1824+
static int Entity__SetTable(ILuaInterface lua) {
1825+
BaseEntity ent = Get_Entity(1, false)!;
1826+
if (g_Lua!.GetType(2) != LuaType.Table) {
1827+
g_Lua.TypeError("table", 2);
1828+
return 0;
1829+
}
1830+
1831+
ILuaObject? table = g_Lua.GetObject(2);
1832+
if (table != null)
1833+
ent.SetLuaTable(table);
1834+
return 0;
1835+
}
1836+
18271837
[LuaMethod]
18281838
static int Entity____newindex(ILuaInterface lua) {
18291839
BaseEntity? ent = Get_Entity(1, true);

0 commit comments

Comments
 (0)