summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--init.lua3
-rw-r--r--pipes.lua40
-rw-r--r--register_flow_logic.lua40
3 files changed, 46 insertions, 37 deletions
diff --git a/init.lua b/init.lua
index 5094a13..6ceca65 100644
--- a/init.lua
+++ b/init.lua
@@ -117,6 +117,9 @@ pipeworks.enable_new_flow_logic = true
if pipeworks.enable_pipes then dofile(pipeworks.modpath.."/pipes.lua") end
if pipeworks.enable_teleport_tube then dofile(pipeworks.modpath.."/teleport_tube.lua") end
if pipeworks.enable_pipe_devices then dofile(pipeworks.modpath.."/devices.lua") end
+-- individual enable flags also checked in register_flow_logic.lua
+if pipeworks.enable_new_flow_logic then dofile(pipeworks.modpath.."/register_flow_logic.lua") end
+
if pipeworks.enable_redefines then
dofile(pipeworks.modpath.."/compat-chests.lua")
dofile(pipeworks.modpath.."/compat-furnaces.lua")
diff --git a/pipes.lua b/pipes.lua
index 4b0b102..54dfbd7 100644
--- a/pipes.lua
+++ b/pipes.lua
@@ -191,6 +191,9 @@ table.insert(pipes_full_nodenames,"pipeworks:valve_on_loaded")
table.insert(pipes_full_nodenames,"pipeworks:entry_panel_loaded")
table.insert(pipes_full_nodenames,"pipeworks:flow_sensor_loaded")
+pipeworks.pipes_full_nodenames = pipes_full_nodenames
+pipeworks.pipes_empty_nodenames = pipes_empty_nodenames
+
@@ -235,42 +238,5 @@ minetest.register_abm({
})
-else
-
-
--- run pressure balancing ABM over all water-moving nodes
--- FIXME: DRY principle, get this from elsewhere in the code
-local pump_on = "pipeworks:pump_on"
-local pump_off = "pipeworks:pump_off"
-
-local pipes_all_nodenames = pipes_full_nodenames
-for _, pipe in ipairs(pipes_empty_nodenames) do
- table.insert(pipes_all_nodenames, pipe)
-end
-table.insert(pipes_all_nodenames, pump_off)
-table.insert(pipes_all_nodenames, pump_on)
-
-
-
-minetest.register_abm({
- nodenames = pipes_all_nodenames,
- interval = 1,
- chance = 1,
- action = function(pos, node, active_object_count, active_object_count_wider)
- pipeworks.balance_pressure(pos, node)
- end
-})
-
--- absorb water into pumps if it'll fit
-minetest.register_abm({
- nodenames = { pump_on },
- interval = 1,
- chance = 1,
- action = function(pos, node, active_object_count, active_object_count_wider)
- pipeworks.run_pump_intake(pos, node)
- end
-})
-
-
end
diff --git a/register_flow_logic.lua b/register_flow_logic.lua
new file mode 100644
index 0000000..e027dae
--- /dev/null
+++ b/register_flow_logic.lua
@@ -0,0 +1,40 @@
+-- register new flow logic ABMs
+
+local pipes_full_nodenames = pipeworks.pipes_full_nodenames
+local pipes_empty_nodenames = pipeworks.pipes_empty_nodenames
+
+-- run pressure balancing ABM over all water-moving nodes
+-- FIXME: DRY principle, get this from elsewhere in the code
+local pump_on = "pipeworks:pump_on"
+local pump_off = "pipeworks:pump_off"
+
+local pipes_all_nodenames = pipes_full_nodenames
+for _, pipe in ipairs(pipes_empty_nodenames) do
+ table.insert(pipes_all_nodenames, pipe)
+end
+table.insert(pipes_all_nodenames, pump_off)
+table.insert(pipes_all_nodenames, pump_on)
+
+
+if pipeworks.enable_pipes then
+ minetest.register_abm({
+ nodenames = pipes_all_nodenames,
+ interval = 1,
+ chance = 1,
+ action = function(pos, node, active_object_count, active_object_count_wider)
+ pipeworks.balance_pressure(pos, node)
+ end
+ })
+end
+
+if pipeworks.enable_pipe_devices then
+ -- absorb water into pumps if it'll fit
+ minetest.register_abm({
+ nodenames = { pump_on },
+ interval = 1,
+ chance = 1,
+ action = function(pos, node, active_object_count, active_object_count_wider)
+ pipeworks.run_pump_intake(pos, node)
+ end
+ })
+end