summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVanessa Ezekowitz <vanessaezekowitz@gmail.com>2017-04-07 19:47:12 -0400
committerVanessa Ezekowitz <vanessaezekowitz@gmail.com>2017-04-07 19:51:54 -0400
commit2c02d792bf42b7db1cc695e80db1401ccb0f591d (patch)
treebbce0d40c3960c6ebaac59a2bc3b1e9f33fda0f1
parentbea570555a87eaf8c9b9daad4953862aaaf4f8e2 (diff)
downloadpipeworks-2c02d792bf42b7db1cc695e80db1401ccb0f591d.tar
pipeworks-2c02d792bf42b7db1cc695e80db1401ccb0f591d.tar.gz
pipeworks-2c02d792bf42b7db1cc695e80db1401ccb0f591d.tar.bz2
pipeworks-2c02d792bf42b7db1cc695e80db1401ccb0f591d.tar.xz
pipeworks-2c02d792bf42b7db1cc695e80db1401ccb0f591d.zip
allow repairing a broken tube
by striking it with cottages:hammer, or castles modpack anvil:hammer, or with any glooptest hammer except wood or stone.
-rw-r--r--routing_tubes.lua31
1 files changed, 30 insertions, 1 deletions
diff --git a/routing_tubes.lua b/routing_tubes.lua
index fa5cefe..6ed0723 100644
--- a/routing_tubes.lua
+++ b/routing_tubes.lua
@@ -28,7 +28,36 @@ pipeworks.register_tube("pipeworks:broken_tube", {
return true
end,
priority = 50,
- }
+ },
+ on_punch = function(pos, node, puncher, pointed_thing)
+ local itemstack = puncher:get_wielded_item()
+ local wieldname = itemstack:get_name()
+ local playername = puncher:get_player_name()
+ print("[Pipeworks] "..playername.." struck a broken tube at "..minetest.pos_to_string(pos))
+ if wieldname == "anvil:hammer"
+ or wieldname == "cottages:hammer"
+ or wieldname == "glooptest:hammer_steel"
+ or wieldname == "glooptest:hammer_bronze"
+ or wieldname == "glooptest:hammer_diamond"
+ or wieldname == "glooptest:hammer_mese"
+ or wieldname == "glooptest:hammer_alatro"
+ or wieldname == "glooptest:hammer_arol" then
+ local meta = minetest.get_meta(pos)
+ local was_node = minetest.deserialize(meta:get_string("the_tube_was"))
+ if was_node and was_node ~= "" then
+ print(" with "..wieldname.." to repair it.")
+ minetest.swap_node(pos, { name = was_node.name, param2 = was_node.param2 })
+ pipeworks.scan_for_tube_objects(pos)
+ itemstack:add_wear(1000)
+ puncher:set_wielded_item(itemstack)
+ return itemstack
+ else
+ print(" but it can't be repaired.")
+ end
+ else
+ print(" with "..wieldname.." but that tool is too weak.")
+ end
+ end
}
})