Add persistent unique identifiers for objects (#14135)
This commit is contained in:
@@ -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 @@ class ObjectRef : public ModApiBase {
|
||||
// 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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user