From 9ab197af2f6e524be920857c0f152aef84546e37 Mon Sep 17 00:00:00 2001 From: thetaepsilon-gamedev Date: Sat, 7 Oct 2017 22:21:54 +0100 Subject: new flow logic: abms.lua: implement non-finite mode behaviour for neighbour output helper --- new_flow_logic/abms.lua | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'new_flow_logic') diff --git a/new_flow_logic/abms.lua b/new_flow_logic/abms.lua index a4d5fc3..99ccbc6 100644 --- a/new_flow_logic/abms.lua +++ b/new_flow_logic/abms.lua @@ -178,9 +178,18 @@ flowlogic.helpers.make_neighbour_output_fixed = function(neighbours) for _, offset in pairs(neighbours) do local npos = vector.add(pos, offset) local name = minetest.get_node(npos).name - if (name == "air") or (name == "default:water_flowing") then + if currentpressure < 1 then break end + -- take pressure anyway in non-finite mode, even if node is water source already. + -- in non-finite mode, pressure has to be sustained to keep the sources there. + -- so in non-finite mode, placing water is dependent on the target node; + -- draining pressure is not. + local canplace = (name == "air") or (name == "default:water_flowing") + if canplace then minetest.swap_node(npos, {name="default:water_source"}) + end + if (not finitemode) or canplace then taken = taken + 1 + currentpressure = currentpressure - 1 end end return taken -- cgit v1.2.3