diff options
author | sfan5 <sfan5@live.de> | 2022-05-25 19:29:11 +0200 |
---|---|---|
committer | sfan5 <sfan5@live.de> | 2022-05-29 14:00:19 +0200 |
commit | f195db2d140a7b4f2f2fbc438680c9d5e23a0d6d (patch) | |
tree | af2e07480ea04277ed2a8d16af42e9e86526f8fe /src/script/lua_api/l_object.cpp | |
parent | da71e86633d0b27cd02d7aac9fdac625d141ca13 (diff) | |
download | minetest-f195db2d140a7b4f2f2fbc438680c9d5e23a0d6d.tar.gz minetest-f195db2d140a7b4f2f2fbc438680c9d5e23a0d6d.tar.bz2 minetest-f195db2d140a7b4f2f2fbc438680c9d5e23a0d6d.zip |
Add API function to invoke player respawn
closes #12272
Diffstat (limited to 'src/script/lua_api/l_object.cpp')
-rw-r--r-- | src/script/lua_api/l_object.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/script/lua_api/l_object.cpp b/src/script/lua_api/l_object.cpp index 39b19364e..37ba1521a 100644 --- a/src/script/lua_api/l_object.cpp +++ b/src/script/lua_api/l_object.cpp @@ -2323,6 +2323,21 @@ int ObjectRef::l_get_lighting(lua_State *L) return 1; } +// respawn(self) +int ObjectRef::l_respawn(lua_State *L) +{ + NO_MAP_LOCK_REQUIRED; + ObjectRef *ref = checkobject(L, 1); + RemotePlayer *player = getplayer(ref); + if (player == nullptr) + return 0; + + getServer(L)->RespawnPlayer(player->getPeerId()); + lua_pushboolean(L, true); + return 1; +} + + ObjectRef::ObjectRef(ServerActiveObject *object): m_object(object) {} @@ -2478,5 +2493,7 @@ luaL_Reg ObjectRef::methods[] = { luamethod(ObjectRef, set_minimap_modes), luamethod(ObjectRef, set_lighting), luamethod(ObjectRef, get_lighting), + luamethod(ObjectRef, respawn), + {0,0} }; |