From 0251baf692741c5cf3173ff9415c94dbbc3719f3 Mon Sep 17 00:00:00 2001 From: thetaepsilon-gamedev Date: Sat, 30 Sep 2017 20:47:00 +0100 Subject: [PATCH] new_flow_logic.lua: move logic functions inside pipeworks.flowlogic sub-table --- new_flow_logic.lua | 13 +++++++++---- register_flow_logic.lua | 4 ++-- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/new_flow_logic.lua b/new_flow_logic.lua index 1b4abf4..a65ac23 100644 --- a/new_flow_logic.lua +++ b/new_flow_logic.lua @@ -3,6 +3,11 @@ +local flowlogic = {} +pipeworks.flowlogic = flowlogic + + + -- borrowed from above: might be useable to replace the above coords tables local make_coords_offsets = function(pos, include_base) local coords = { @@ -28,7 +33,7 @@ end -- and returns it so that the receptacle can update it's pressure values. -- this should ensure that water blocks aren't vanished from existance. -- will take care of zero or negative-valued limits. -pipeworks.check_for_liquids_v2 = function(pos, limit) +flowlogic.check_for_liquids_v2 = function(pos, limit) if not limit then limit = 6 end @@ -50,7 +55,7 @@ end local label_pressure = "pipeworks.water_pressure" local label_haspressure = "pipeworks.is_pressure_node" -pipeworks.balance_pressure = function(pos, node) +flowlogic.balance_pressure = function(pos, node) -- debuglog("balance_pressure() "..node.name.." at "..pos.x.." "..pos.y.." "..pos.z) -- check the pressure of all nearby nodes, and average it out. -- for the moment, only balance neighbour nodes if it already has a pressure value. @@ -84,7 +89,7 @@ end -pipeworks.run_pump_intake = function(pos, node) +flowlogic.run_pump_intake = function(pos, node) -- try to absorb nearby water nodes, but only up to limit. -- NB: check_for_liquids_v2 handles zero or negative from the following subtraction @@ -103,7 +108,7 @@ end -pipeworks.run_spigot_output = function(pos, node) +flowlogic.run_spigot_output = function(pos, node) -- try to output a water source node if there's enough pressure and space below. local meta = minetest.get_meta(pos) local currentpressure = meta:get_float(label_pressure) diff --git a/register_flow_logic.lua b/register_flow_logic.lua index 8580188..3a8df8e 100644 --- a/register_flow_logic.lua +++ b/register_flow_logic.lua @@ -23,7 +23,7 @@ minetest.register_abm({ interval = 1, chance = 1, action = function(pos, node, active_object_count, active_object_count_wider) - pipeworks.balance_pressure(pos, node) + pipeworks.flowlogic.balance_pressure(pos, node) end }) @@ -34,7 +34,7 @@ if pipeworks.enable_pipe_devices then interval = 1, chance = 1, action = function(pos, node, active_object_count, active_object_count_wider) - pipeworks.run_pump_intake(pos, node) + pipeworks.flowlogic.run_pump_intake(pos, node) end })