From f82570f58027ec7659c4050124fdc15d1203dbd8 Mon Sep 17 00:00:00 2001 From: thetaepsilon-gamedev Date: Wed, 27 Sep 2017 14:14:33 +0100 Subject: initial stub patches to re-implement new_flow_logic --- pipes.lua | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'pipes.lua') diff --git a/pipes.lua b/pipes.lua index 9771e3b..5a48801 100644 --- a/pipes.lua +++ b/pipes.lua @@ -227,3 +227,17 @@ minetest.register_abm({ end }) + +-- run pressure balancing ABM over all water-moving nodes +local pipes_all_nodenames = pipes_full_nodenames +for _, pipe in ipairs(pipes_empty_nodenames) do + table.insert(pipes_all_nodenames, pipe) +end +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 +}) -- cgit v1.2.3 From 59ac9780939b9c130bb70034bccb04ff1e99136d Mon Sep 17 00:00:00 2001 From: thetaepsilon-gamedev Date: Wed, 27 Sep 2017 15:19:20 +0100 Subject: pipes.lua: place old ABM code registration behind if-guard for new flag --- pipes.lua | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'pipes.lua') diff --git a/pipes.lua b/pipes.lua index 5a48801..29f91d3 100644 --- a/pipes.lua +++ b/pipes.lua @@ -191,6 +191,13 @@ 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") + + + +if not pipeworks.enable_new_flow_logic then +-- sorry, no indents... it messes with the patchlogs too much + + minetest.register_abm({ nodenames = pipes_empty_nodenames, interval = 1, @@ -228,6 +235,9 @@ minetest.register_abm({ }) +else + + -- run pressure balancing ABM over all water-moving nodes local pipes_all_nodenames = pipes_full_nodenames for _, pipe in ipairs(pipes_empty_nodenames) do @@ -241,3 +251,7 @@ minetest.register_abm({ pipeworks.balance_pressure(pos, node) end }) + + + +end \ No newline at end of file -- cgit v1.2.3 From 67350b55bb00a8787ebfa3e5ab6763748cfd792d Mon Sep 17 00:00:00 2001 From: thetaepsilon-gamedev Date: Wed, 27 Sep 2017 16:20:07 +0100 Subject: pipes.lua: wire up pump intake ABM and add pumps to balancing logic --- pipes.lua | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'pipes.lua') diff --git a/pipes.lua b/pipes.lua index 29f91d3..4b0b102 100644 --- a/pipes.lua +++ b/pipes.lua @@ -239,10 +239,19 @@ 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, @@ -252,6 +261,16 @@ minetest.register_abm({ 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 \ No newline at end of file +end -- cgit v1.2.3 From 69133818f7283ea3a8b14060b71df769cac9eb48 Mon Sep 17 00:00:00 2001 From: thetaepsilon-gamedev Date: Wed, 27 Sep 2017 17:00:18 +0100 Subject: pipes.lua: split out new flow logic registration and make it respect feature toggles --- pipes.lua | 40 +++------------------------------------- 1 file changed, 3 insertions(+), 37 deletions(-) (limited to 'pipes.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 -- cgit v1.2.3