summaryrefslogtreecommitdiff
path: root/pipeworks
diff options
context:
space:
mode:
Diffstat (limited to 'pipeworks')
-rw-r--r--pipeworks/autoplace_tubes.lua16
-rw-r--r--pipeworks/decorative_tubes.lua2
-rw-r--r--pipeworks/routing_tubes.lua1
-rw-r--r--pipeworks/tube_registration.lua1
4 files changed, 20 insertions, 0 deletions
diff --git a/pipeworks/autoplace_tubes.lua b/pipeworks/autoplace_tubes.lua
index 0d28e64..a3a6aee 100644
--- a/pipeworks/autoplace_tubes.lua
+++ b/pipeworks/autoplace_tubes.lua
@@ -111,6 +111,22 @@ function pipeworks.after_dig(pos)
pipeworks.scan_for_tube_objects(pos)
end
+-- Screwdriver calls this function before rotating a node.
+-- However, connections must be updated *after* the node is rotated
+-- So, this function does the rotation itself and returns `true`.
+-- (Note: screwdriver already checks for protected areas.)
+
+-- This should only be used for tubes that don't autoconnect.
+-- (For example, one-way tubes.)
+-- Autoconnecting tubes will just revert back to their original state
+-- when they are updated.
+function pipeworks.on_rotate(pos, node, user, mode, new_param2)
+ node.param2 = new_param2
+ minetest.set_node(pos, node)
+ pipeworks.scan_for_tube_objects(pos)
+ return true
+end
+
if minetest.get_modpath("mesecons_mvps") then
mesecon.register_on_mvps_move(function(moved_nodes)
for _, n in ipairs(moved_nodes) do
diff --git a/pipeworks/decorative_tubes.lua b/pipeworks/decorative_tubes.lua
index 39ba8f3..2b48b6b 100644
--- a/pipeworks/decorative_tubes.lua
+++ b/pipeworks/decorative_tubes.lua
@@ -24,6 +24,7 @@ minetest.register_node("pipeworks:steel_block_embedded_tube", {
},
after_place_node = pipeworks.after_place,
after_dig_node = pipeworks.after_dig,
+ on_rotate = pipeworks.on_rotate,
})
minetest.register_craft( {
@@ -71,6 +72,7 @@ minetest.register_node("pipeworks:steel_pane_embedded_tube", {
},
after_place_node = pipeworks.after_place,
after_dig_node = pipeworks.after_dig,
+ on_rotate = pipeworks.on_rotate,
})
minetest.register_craft( {
diff --git a/pipeworks/routing_tubes.lua b/pipeworks/routing_tubes.lua
index ba9e0aa..e2f1af4 100644
--- a/pipeworks/routing_tubes.lua
+++ b/pipeworks/routing_tubes.lua
@@ -161,6 +161,7 @@ if pipeworks.enable_one_way_tube then
},
after_place_node = pipeworks.after_place,
after_dig_node = pipeworks.after_dig,
+ on_rotate = pipeworks.on_rotate,
})
minetest.register_craft({
output = "pipeworks:one_way_tube 2",
diff --git a/pipeworks/tube_registration.lua b/pipeworks/tube_registration.lua
index 48fa912..7bef10e 100644
--- a/pipeworks/tube_registration.lua
+++ b/pipeworks/tube_registration.lua
@@ -108,6 +108,7 @@ local register_one_tube = function(name, tname, dropname, desc, plain, noctrs, e
},
after_place_node = pipeworks.after_place,
after_dig_node = pipeworks.after_dig,
+ on_rotate = false,
on_blast = function(pos, intensity)
if not intensity or intensity > 1 + 3^0.5 then
minetest.remove_node(pos)