Add minetest.override_item

This commit is contained in:
ShadowNinja 2014-01-13 19:28:55 -05:00 committed by Nils Dagsson Moskopp
parent c5acb54340
commit 7e24d1ec9c
Signed by: erle
GPG Key ID: A3BC671C35191080
1 changed files with 18 additions and 0 deletions

View File

@ -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