diff options
author | Novatux <nathanael.courant@laposte.net> | 2014-07-02 14:29:51 +0200 |
---|---|---|
committer | Novatux <nathanael.courant@laposte.net> | 2014-07-02 14:29:51 +0200 |
commit | f8bbe908cdd3d35c7049ac3fea792d9287ea9beb (patch) | |
tree | 3046ce04fa058dbf857ae447298d0cdd772ccdc1 /node_breaker.lua | |
parent | df1c9d087492d1f518d721551e834fb43ede8aaf (diff) | |
download | pipeworks-f8bbe908cdd3d35c7049ac3fea792d9287ea9beb.tar pipeworks-f8bbe908cdd3d35c7049ac3fea792d9287ea9beb.tar.gz pipeworks-f8bbe908cdd3d35c7049ac3fea792d9287ea9beb.tar.bz2 pipeworks-f8bbe908cdd3d35c7049ac3fea792d9287ea9beb.tar.xz pipeworks-f8bbe908cdd3d35c7049ac3fea792d9287ea9beb.zip |
Don't wear tools out in nodebreaker if it's mechanical wear (tools which are repaired by the tool workshop of technic)
Diffstat (limited to 'node_breaker.lua')
-rw-r--r-- | node_breaker.lua | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/node_breaker.lua b/node_breaker.lua index a25ca32..03df35c 100644 --- a/node_breaker.lua +++ b/node_breaker.lua @@ -168,14 +168,21 @@ local function break_node (pos, facedir) set_bone_position = delay(), } - if pick_inv == "pick" and minetest.registered_items[pick:get_name()] and minetest.registered_items[pick:get_name()].on_use then + local pickdef = minetest.registered_items[pick:get_name()] + local pickcopy = ItemStack(pick) + if pick_inv == "pick" and pickdef and pickdef.on_use then local pos_under, pos_above = {x = pos.x - vel.x, y = pos.y - vel.y, z = pos.z - vel.z}, {x = pos.x - 2*vel.x, y = pos.y - 2*vel.y, z = pos.z - 2*vel.z} local pointed_thing = {type="node", under=pos_under, above=pos_above} - inv:set_stack(pick_inv, 1, minetest.registered_items[pick:get_name()].on_use(pick, digger, pointed_thing) or pick) + inv:set_stack(pick_inv, 1, pickdef.on_use(pick, digger, pointed_thing) or pick) else minetest.node_dig(front, node, digger) end + + if pickdef and (not pickdef.wear_represents or pickdef.wear_represents == "mechanical_wear") then + inv:set_stack(pick_inv, 1, pickcopy) -- Do not wear pick out + end + for i = 1, 100 do local dropped_item = inv:get_stack("main", i) if not dropped_item:is_empty() then |