mirror of
https://github.com/luanti-org/luanti.git
synced 2025-09-05 18:41:05 +00:00
Add persistent unique identifiers for objects (#14135)
This commit is contained in:
parent
e0f8243629
commit
4f42b4308c
20 changed files with 257 additions and 19 deletions
|
@ -119,6 +119,20 @@ int ObjectRef::l_is_valid(lua_State *L)
|
|||
return 1;
|
||||
}
|
||||
|
||||
// get_guid()
|
||||
int ObjectRef::l_get_guid(lua_State *L)
|
||||
{
|
||||
NO_MAP_LOCK_REQUIRED;
|
||||
ObjectRef *ref = checkObject<ObjectRef>(L, 1);
|
||||
ServerActiveObject *sao = getobject(ref);
|
||||
if (sao == nullptr)
|
||||
return 0;
|
||||
|
||||
std::string guid = sao->getGUID();
|
||||
lua_pushlstring(L, guid.c_str(), guid.size());
|
||||
return 1;
|
||||
}
|
||||
|
||||
// get_pos(self)
|
||||
int ObjectRef::l_get_pos(lua_State *L)
|
||||
{
|
||||
|
@ -2838,6 +2852,7 @@ luaL_Reg ObjectRef::methods[] = {
|
|||
// ServerActiveObject
|
||||
luamethod(ObjectRef, remove),
|
||||
luamethod(ObjectRef, is_valid),
|
||||
luamethod(ObjectRef, get_guid),
|
||||
luamethod_aliased(ObjectRef, get_pos, getpos),
|
||||
luamethod_aliased(ObjectRef, set_pos, setpos),
|
||||
luamethod(ObjectRef, add_pos),
|
||||
|
|
|
@ -61,6 +61,9 @@ private:
|
|||
// is_valid(self)
|
||||
static int l_is_valid(lua_State *L);
|
||||
|
||||
// get_guid()
|
||||
static int l_get_guid(lua_State *L);
|
||||
|
||||
// get_pos(self)
|
||||
static int l_get_pos(lua_State *L);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue