From 00e605c0f9e2f4c54520f3a3e5b181099b1e828e Mon Sep 17 00:00:00 2001 From: cora Date: Tue, 22 Dec 2020 17:55:22 +0100 Subject: [PATCH] clientobject: add get_id() --- src/script/lua_api/l_clientobject.cpp | 8 ++++++++ src/script/lua_api/l_clientobject.h | 2 ++ 2 files changed, 10 insertions(+) diff --git a/src/script/lua_api/l_clientobject.cpp b/src/script/lua_api/l_clientobject.cpp index b2e708ffe..2adcff1a4 100644 --- a/src/script/lua_api/l_clientobject.cpp +++ b/src/script/lua_api/l_clientobject.cpp @@ -32,6 +32,13 @@ GenericCAO *ClientObjectRef::get_generic_cao(ClientObjectRef *ref, lua_State *L) GenericCAO *gcao = env.getGenericCAO(obj->getId()); return gcao; } +int ClientObjectRef::l_get_id(lua_State *L) +{ + ClientObjectRef *ref = checkobject(L, 1); + GenericCAO *gcao = get_generic_cao(ref, L); + lua_pushvalue(L, gcao->getId()); + return 1; +} int ClientObjectRef::l_get_pos(lua_State *L) { @@ -224,6 +231,7 @@ void ClientObjectRef::Register(lua_State *L) const char ClientObjectRef::className[] = "ClientObjectRef"; luaL_Reg ClientObjectRef::methods[] = { + luamethod(ClientObjectRef, get_id), luamethod(ClientObjectRef, get_pos), luamethod(ClientObjectRef, get_velocity), luamethod(ClientObjectRef, get_acceleration), diff --git a/src/script/lua_api/l_clientobject.h b/src/script/lua_api/l_clientobject.h index 6ac48a2b5..e228d24cc 100644 --- a/src/script/lua_api/l_clientobject.h +++ b/src/script/lua_api/l_clientobject.h @@ -31,6 +31,8 @@ private: static int gc_object(lua_State *L); + static int l_get_id(lua_State *L); + // get_pos(self) // returns: {x=num, y=num, z=num} static int l_get_pos(lua_State *L); -- 2.11.4.GIT