diff options
author | Perttu Ahola <celeron55@gmail.com> | 2012-04-09 21:14:16 +0300 |
---|---|---|
committer | Perttu Ahola <celeron55@gmail.com> | 2012-04-09 21:14:16 +0300 |
commit | 07a5e59ae72cca5a8e58dca7210e5992d8e9d527 (patch) | |
tree | 00b63dcc7be8da5c27b1ec81c3c8de13cfeccd70 | |
parent | f8c2f1cf54c3328abf994d146858b47029c98b3d (diff) | |
download | minetest-07a5e59ae72cca5a8e58dca7210e5992d8e9d527.tar.gz minetest-07a5e59ae72cca5a8e58dca7210e5992d8e9d527.tar.bz2 minetest-07a5e59ae72cca5a8e58dca7210e5992d8e9d527.zip |
Allow redefining minetest.item_place and the like
-rw-r--r-- | builtin/item.lua | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/builtin/item.lua b/builtin/item.lua index 678a5cdac..440236fbe 100644 --- a/builtin/item.lua +++ b/builtin/item.lua @@ -276,6 +276,13 @@ function minetest.node_dig(pos, node, digger) end end +-- This is used to allow mods to redefine minetest.item_place and so on +local function redef_wrapper(table, name) + return function(...) + return table[name](...) + end +end + -- -- Item definition defaults -- @@ -295,12 +302,12 @@ minetest.nodedef_default = { tool_capabilities = nil, -- Interaction callbacks - on_place = minetest.item_place, - on_drop = minetest.item_drop, + on_place = redef_wrapper(minetest, 'item_place'), -- minetest.item_place + on_drop = redef_wrapper(minetest, 'item_drop'), -- minetest.item_drop on_use = nil, - on_punch = minetest.node_punch, - on_dig = minetest.node_dig, + on_punch = redef_wrapper(minetest, 'node_punch'), -- minetest.node_punch + on_dig = redef_wrapper(minetest, 'node_dig'), -- minetest.node_dig -- Node properties drawtype = "normal", @@ -346,8 +353,8 @@ minetest.craftitemdef_default = { tool_capabilities = nil, -- Interaction callbacks - on_place = minetest.item_place, - on_drop = minetest.item_drop, + on_place = redef_wrapper(minetest, 'item_place'), -- minetest.item_place + on_drop = redef_wrapper(minetest, 'item_drop'), -- minetest.item_drop on_use = nil, } @@ -364,8 +371,8 @@ minetest.tooldef_default = { tool_capabilities = nil, -- Interaction callbacks - on_place = minetest.item_place, - on_drop = minetest.item_drop, + on_place = redef_wrapper(minetest, 'item_place'), -- minetest.item_place + on_drop = redef_wrapper(minetest, 'item_drop'), -- minetest.item_drop on_use = nil, } |