diff options
author | paly2 <plangrognet@laposte.net> | 2016-07-10 15:15:43 +0200 |
---|---|---|
committer | kwolekr <kwolekr@minetest.net> | 2016-09-08 03:26:52 -0400 |
commit | aa33166386f737f213f1f3005ffd6a6adfd2d97f (patch) | |
tree | 6ddbec97ff34fd231a7cb23e70d1dc7dce6049cb /src/script | |
parent | 7eacdc7bb8ec8f8b06b5e0b2464af219e623cd56 (diff) | |
download | minetest-aa33166386f737f213f1f3005ffd6a6adfd2d97f.tar.gz minetest-aa33166386f737f213f1f3005ffd6a6adfd2d97f.tar.bz2 minetest-aa33166386f737f213f1f3005ffd6a6adfd2d97f.zip |
Add minetest.unregister_item and minetest.register_alias_force
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); |