From 30bedbfecc57f515f3c8578e225e27671e52316b Mon Sep 17 00:00:00 2001 From: thetaepsilon-gamedev Date: Sun, 15 Oct 2017 18:18:48 +0100 Subject: [PATCH] new flow logic: abms.lua: hoist simple flowable neighbour calculation into if-block in preparation for directional flowables support --- new_flow_logic/abms.lua | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/new_flow_logic/abms.lua b/new_flow_logic/abms.lua index 38ae4b6..0b0b799 100644 --- a/new_flow_logic/abms.lua +++ b/new_flow_logic/abms.lua @@ -131,8 +131,17 @@ flowlogic.balance_pressure = function(pos, node, currentpressure) local totalv = currentpressure local totalc = 1 + -- get list of node neighbours. + -- if this node is directional and only flows on certain sides, + -- invoke the callback to retrieve the set. + -- for simple flowables this is just an auto-gen'd list of all six possible neighbours. + local candidates = {} + if pipeworks.flowables.list.simple[node.name] then + candidates = make_coords_offsets(pos, false) + end + -- then handle neighbours, but if not a pressure node don't consider them at all - for _, npos in ipairs(make_coords_offsets(pos, false)) do + for _, npos in ipairs(candidates) do local nodename = minetest.get_node(npos).name -- for now, just check if it's in the simple table. -- TODO: the "can flow from" logic in flowable_node_registry.lua