new flow logic: abms.lua: implement non-finite mode behaviour for neighbour output helper

This commit is contained in:
thetaepsilon-gamedev 2017-10-07 22:21:54 +01:00
parent 07e769d1b9
commit 9ab197af2f

View File

@ -178,9 +178,18 @@ flowlogic.helpers.make_neighbour_output_fixed = function(neighbours)
for _, offset in pairs(neighbours) do for _, offset in pairs(neighbours) do
local npos = vector.add(pos, offset) local npos = vector.add(pos, offset)
local name = minetest.get_node(npos).name 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"}) minetest.swap_node(npos, {name="default:water_source"})
end
if (not finitemode) or canplace then
taken = taken + 1 taken = taken + 1
currentpressure = currentpressure - 1
end end
end end
return taken return taken