summaryrefslogtreecommitdiff
path: root/routing_tubes.lua
diff options
context:
space:
mode:
Diffstat (limited to 'routing_tubes.lua')
-rw-r--r--routing_tubes.lua54
1 files changed, 53 insertions, 1 deletions
diff --git a/routing_tubes.lua b/routing_tubes.lua
index 0a82fc8..6ed0723 100644
--- a/routing_tubes.lua
+++ b/routing_tubes.lua
@@ -1,3 +1,4 @@
+
-- the default tube and default textures
pipeworks.register_tube("pipeworks:tube", "Pneumatic tube segment")
minetest.register_craft( {
@@ -9,6 +10,57 @@ minetest.register_craft( {
},
})
+pipeworks.register_tube("pipeworks:broken_tube", {
+ description = "Broken Tube (you hacker you)",
+ plain = { { name = "pipeworks_broken_tube_plain.png", backface_culling = false, color = nodecolor } },
+ noctr = { { name = "pipeworks_broken_tube_plain.png", backface_culling = false, color = nodecolor } },
+ ends = { { name = "pipeworks_broken_tube_end.png", color = nodecolor } },
+ short = { name = "pipeworks_broken_tube_short.png", color = nodecolor },
+ node_def = {
+ drop = "pipeworks:tube_1",
+ groups = {not_in_creative_inventory = 1, tubedevice_receiver = 1},
+ tube = {
+ insert_object = function(pos, node, stack, direction)
+ minetest.item_drop(stack, nil, pos)
+ return ItemStack("")
+ end,
+ can_insert = function(pos,node,stack,direction)
+ 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
+ }
+})
+
-- the high priority tube is a low-cpu replacement for sorting tubes in situations
-- where players would use them for simple routing (turning off paths)
-- without doing actual sorting, like at outputs of tubedevices that might both accept and eject items
@@ -101,7 +153,7 @@ if pipeworks.enable_one_way_tube then
return {velocity}
end,
can_insert = function(pos, node, stack, direction)
- local dir = minetest.facedir_to_right_dir(node.param2)
+ local dir = pipeworks.facedir_to_right_dir(node.param2)
return vector.equals(dir, direction)
end,
priority = 75 -- Higher than normal tubes, but lower than receivers