diff options
Diffstat (limited to 'src/script')
-rw-r--r-- | src/script/lua_api/l_item.cpp | 22 | ||||
-rw-r--r-- | src/script/lua_api/l_item.h | 1 |
2 files changed, 23 insertions, 0 deletions
diff --git a/src/script/lua_api/l_item.cpp b/src/script/lua_api/l_item.cpp index 5381cba76..ff0baea14 100644 --- a/src/script/lua_api/l_item.cpp +++ b/src/script/lua_api/l_item.cpp @@ -525,6 +525,27 @@ int ModApiItemMod::l_register_item_raw(lua_State *L) return 0; /* number of results */ } +// unregister_item(name) +int ModApiItemMod::l_unregister_item_raw(lua_State *L) +{ + NO_MAP_LOCK_REQUIRED; + std::string name = luaL_checkstring(L, 1); + + IWritableItemDefManager *idef = + getServer(L)->getWritableItemDefManager(); + + // Unregister the node + if (idef->get(name).type == ITEM_NODE) { + IWritableNodeDefManager *ndef = + getServer(L)->getWritableNodeDefManager(); + ndef->removeNode(name); + } + + idef->unregisterItem(name); + + return 0; /* number of results */ +} + // register_alias_raw(name, convert_to_name) int ModApiItemMod::l_register_alias_raw(lua_State *L) { @@ -570,6 +591,7 @@ int ModApiItemMod::l_get_name_from_content_id(lua_State *L) void ModApiItemMod::Initialize(lua_State *L, int top) { API_FCT(register_item_raw); + API_FCT(unregister_item_raw); API_FCT(register_alias_raw); API_FCT(get_content_id); API_FCT(get_name_from_content_id); diff --git a/src/script/lua_api/l_item.h b/src/script/lua_api/l_item.h index 0f9e4ba9b..be919b701 100644 --- a/src/script/lua_api/l_item.h +++ b/src/script/lua_api/l_item.h @@ -135,6 +135,7 @@ public: class ModApiItemMod : public ModApiBase { private: static int l_register_item_raw(lua_State *L); + static int l_unregister_item_raw(lua_State *L); static int l_register_alias_raw(lua_State *L); static int l_get_content_id(lua_State *L); static int l_get_name_from_content_id(lua_State *L); |