aboutsummaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorNovatux <nathanael.courant@laposte.net>2013-05-06 18:53:15 +0200
committerproller <proller@github.com>2013-10-16 21:58:29 +0400
commit34e0a0ca0fbb6826ea0c583295f79307b1a754c6 (patch)
tree25397c2e2d93d5438f35e5cfea83adf446f3cc78 /builtin
parent4e5760a5416cbca6945b1b4484cbd96bea7b250c (diff)
downloadminetest-34e0a0ca0fbb6826ea0c583295f79307b1a754c6.tar.gz
minetest-34e0a0ca0fbb6826ea0c583295f79307b1a754c6.tar.bz2
minetest-34e0a0ca0fbb6826ea0c583295f79307b1a754c6.zip
Add tool callback
Diffstat (limited to 'builtin')
-rw-r--r--builtin/item.lua19
1 files changed, 12 insertions, 7 deletions
diff --git a/builtin/item.lua b/builtin/item.lua
index f07566b8c..7f20d30c5 100644
--- a/builtin/item.lua
+++ b/builtin/item.lua
@@ -383,14 +383,19 @@ function minetest.node_dig(pos, node, digger)
local wielded = digger:get_wielded_item()
local drops = minetest.get_node_drops(node.name, wielded:get_name())
-
- -- Wear out tool
- if not minetest.setting_getbool("creative_mode") then
- local tp = wielded:get_tool_capabilities()
- local dp = minetest.get_dig_params(def.groups, tp)
- wielded:add_wear(dp.wear)
- digger:set_wielded_item(wielded)
+
+ local wdef = wielded:get_definition()
+ local tp = wielded:get_tool_capabilities()
+ local dp = minetest.get_dig_params(def.groups, tp)
+ if wdef and wdef.after_use then
+ wielded = wdef.after_use(wielded, digger, node, dp) or wielded
+ else
+ -- Wear out tool
+ if not minetest.setting_getbool("creative_mode") then
+ wielded:add_wear(dp.wear)
+ end
end
+ digger:set_wielded_item(wielded)
-- Handle drops
minetest.handle_node_drops(pos, drops, digger)