From efe2af2d20e70538c75f4fb592b7a8295a310f1e Mon Sep 17 00:00:00 2001 From: Tim Date: Wed, 4 Feb 2015 13:01:55 +0100 Subject: [PATCH] let the requested wielditem be the actual current wielditem and not just the initialized one clean up some code to make a few lesser calls to it --- wielder.lua | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/wielder.lua b/wielder.lua index 3ce73f6..3461013 100644 --- a/wielder.lua +++ b/wielder.lua @@ -90,7 +90,10 @@ local function wielder_on(data, wielder_pos, wielder_node) setpos = delay(), set_hp = delay(), set_properties = delay(), - set_wielded_item = function(self, item) inv:set_stack(wield_inv_name, wieldindex, item) end, + set_wielded_item = function(self, item) + wieldstack = item + inv:set_stack(wield_inv_name, wieldindex, item) + end, set_animation = delay(), set_attach = delay(), set_detach = delay(), @@ -317,13 +320,14 @@ if pipeworks.enable_node_breaker then local oldwieldstack = ItemStack(wieldstack) local on_use = (minetest.registered_items[wieldstack:get_name()] or {}).on_use if on_use then - virtplayer:set_wielded_item(on_use(wieldstack, virtplayer, pointed_thing) or wieldstack) + wieldstack = on_use(wieldstack, virtplayer, pointed_thing) or wieldstack + virtplayer:set_wielded_item(wieldstack) else local under_node = minetest.get_node(pointed_thing.under) local on_dig = (minetest.registered_nodes[under_node.name] or {on_dig=minetest.node_dig}).on_dig on_dig(pointed_thing.under, under_node, virtplayer) + wieldstack = virtplayer:get_wielded_item() end - wieldstack = virtplayer:get_wielded_item() local wieldname = wieldstack:get_name() if wieldname == oldwieldstack:get_name() then -- don't mechanically wear out tool