summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim <t4im@users.noreply.github.com>2015-02-04 13:01:55 +0100
committerTim <t4im@users.noreply.github.com>2015-02-04 13:01:55 +0100
commitefe2af2d20e70538c75f4fb592b7a8295a310f1e (patch)
tree022798998d54c33ae6fef86430cce640240a90ad
parente53cd28fcbe8bb87389a6c0658a4321b2ae7eb47 (diff)
downloadpipeworks-efe2af2d20e70538c75f4fb592b7a8295a310f1e.tar
pipeworks-efe2af2d20e70538c75f4fb592b7a8295a310f1e.tar.gz
pipeworks-efe2af2d20e70538c75f4fb592b7a8295a310f1e.tar.bz2
pipeworks-efe2af2d20e70538c75f4fb592b7a8295a310f1e.tar.xz
pipeworks-efe2af2d20e70538c75f4fb592b7a8295a310f1e.zip
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
-rw-r--r--wielder.lua10
1 files 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