diff options
Diffstat (limited to 'src/script/lua_api')
-rw-r--r-- | src/script/lua_api/l_object.cpp | 33 | ||||
-rw-r--r-- | src/script/lua_api/l_object.h | 6 |
2 files changed, 39 insertions, 0 deletions
diff --git a/src/script/lua_api/l_object.cpp b/src/script/lua_api/l_object.cpp index f72a81d32..5fc6f9d3c 100644 --- a/src/script/lua_api/l_object.cpp +++ b/src/script/lua_api/l_object.cpp @@ -1244,6 +1244,37 @@ int ObjectRef::l_get_inventory_formspec(lua_State *L) return 1; } +// set_formspec_prepend(self, formspec) +int ObjectRef::l_set_formspec_prepend(lua_State *L) +{ + NO_MAP_LOCK_REQUIRED; + ObjectRef *ref = checkobject(L, 1); + RemotePlayer *player = getplayer(ref); + if (player == NULL) + return 0; + + std::string formspec = luaL_checkstring(L, 2); + + player->formspec_prepend = formspec; + getServer(L)->reportFormspecPrependModified(player->getName()); + lua_pushboolean(L, true); + return 1; +} + +// get_formspec_prepend(self) -> formspec +int ObjectRef::l_get_formspec_prepend(lua_State *L) +{ + NO_MAP_LOCK_REQUIRED; + ObjectRef *ref = checkobject(L, 1); + RemotePlayer *player = getplayer(ref); + if (player == NULL) + return 0; + + std::string formspec = player->formspec_prepend; + lua_pushlstring(L, formspec.c_str(), formspec.size()); + return 1; +} + // get_player_control(self) int ObjectRef::l_get_player_control(lua_State *L) { @@ -1817,6 +1848,8 @@ const luaL_Reg ObjectRef::methods[] = { luamethod(ObjectRef, set_attribute), luamethod(ObjectRef, set_inventory_formspec), luamethod(ObjectRef, get_inventory_formspec), + luamethod(ObjectRef, set_formspec_prepend), + luamethod(ObjectRef, get_formspec_prepend), luamethod(ObjectRef, get_player_control), luamethod(ObjectRef, get_player_control_bits), luamethod(ObjectRef, set_physics_override), diff --git a/src/script/lua_api/l_object.h b/src/script/lua_api/l_object.h index 2a76d8a70..58cfe7146 100644 --- a/src/script/lua_api/l_object.h +++ b/src/script/lua_api/l_object.h @@ -253,6 +253,12 @@ private: // get_inventory_formspec(self) -> formspec static int l_get_inventory_formspec(lua_State *L); + // set_formspec_prepend(self, formspec) + static int l_set_formspec_prepend(lua_State *L); + + // get_formspec_prepend(self) -> formspec + static int l_get_formspec_prepend(lua_State *L); + // get_player_control(self) static int l_get_player_control(lua_State *L); |