aboutsummaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorShadowNinja <shadowninja@minetest.net>2014-01-13 19:28:55 -0500
committerShadowNinja <shadowninja@minetest.net>2014-01-13 21:41:00 -0500
commit574ed6a363328dcfa477b1779f3d9491322d96b7 (patch)
tree48d49020856319d7f4f669fd94dc3026b02089f2 /builtin
parent8966c16ad298f94be1f4542afa6b081a1d286eda (diff)
downloadminetest-574ed6a363328dcfa477b1779f3d9491322d96b7.tar.gz
minetest-574ed6a363328dcfa477b1779f3d9491322d96b7.tar.bz2
minetest-574ed6a363328dcfa477b1779f3d9491322d96b7.zip
Add minetest.override_item
Diffstat (limited to 'builtin')
-rw-r--r--builtin/misc_register.lua18
1 files changed, 18 insertions, 0 deletions
diff --git a/builtin/misc_register.lua b/builtin/misc_register.lua
index 6c50ff02e..d00945dbd 100644
--- a/builtin/misc_register.lua
+++ b/builtin/misc_register.lua
@@ -315,6 +315,24 @@ minetest.register_item(":", {
})
+function minetest.override_item(name, redefinition)
+ if redefinition.name ~= nil then
+ error("Attemt to redefine name of "..name.." to "..dump(redefinition.name), 2)
+ end
+ if redefinition.type ~= nil then
+ error("Attemt to redefine type of "..name.." to "..dump(redefinition.type), 2)
+ end
+ local item = minetest.registered_items[name]
+ if not item then
+ error("Attemt to override non-existent item "..name, 2)
+ end
+ for k, v in pairs(redefinition) do
+ rawset(item, k, v)
+ end
+ register_item_raw(item)
+end
+
+
function minetest.run_callbacks(callbacks, mode, ...)
assert(type(callbacks) == "table")
local cb_len = #callbacks