summaryrefslogtreecommitdiff
path: root/pressure_logic/abms.lua
diff options
context:
space:
mode:
Diffstat (limited to 'pressure_logic/abms.lua')
-rw-r--r--pressure_logic/abms.lua30
1 files changed, 19 insertions, 11 deletions
diff --git a/pressure_logic/abms.lua b/pressure_logic/abms.lua
index c14c124..b79050b 100644
--- a/pressure_logic/abms.lua
+++ b/pressure_logic/abms.lua
@@ -130,17 +130,7 @@ end
-flowlogic.balance_pressure = function(pos, node, currentpressure)
- -- local dname = "flowlogic.balance_pressure()@"..formatvec(pos).." "
- -- check the pressure of all nearby flowable nodes, and average it out.
-
- -- pressure handles to average over
- local connections = {}
- -- unconditionally include self in nodes to average over.
- -- result of averaging will be returned as new pressure for main flow logic callback
- local totalv = currentpressure
- local totalc = 1
-
+local get_neighbour_positions = function(pos, node)
-- get list of node neighbours.
-- if this node is directional and only flows on certain sides,
-- invoke the callback to retrieve the set.
@@ -158,6 +148,24 @@ flowlogic.balance_pressure = function(pos, node, currentpressure)
end
end
+ return candidates
+end
+
+
+
+flowlogic.balance_pressure = function(pos, node, currentpressure)
+ -- local dname = "flowlogic.balance_pressure()@"..formatvec(pos).." "
+ -- check the pressure of all nearby flowable nodes, and average it out.
+
+ -- pressure handles to average over
+ local connections = {}
+ -- unconditionally include self in nodes to average over.
+ -- result of averaging will be returned as new pressure for main flow logic callback
+ local totalv = currentpressure
+ local totalc = 1
+
+ local candidates = get_neighbour_positions(pos, node)
+
-- then handle neighbours, but if not a pressure node don't consider them at all
for _, npos in ipairs(candidates) do
local nodename = minetest.get_node(npos).name