From 6f90ee0875dd0f89f460b6ae75acac708a63cb4c Mon Sep 17 00:00:00 2001 From: thetaepsilon-gamedev Date: Sat, 7 Oct 2017 13:24:46 +0100 Subject: new flow logic: abms.lua: add companion cleaner helper for neighbour output --- new_flow_logic/abms.lua | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'new_flow_logic') diff --git a/new_flow_logic/abms.lua b/new_flow_logic/abms.lua index 15adcef..7a720be 100644 --- a/new_flow_logic/abms.lua +++ b/new_flow_logic/abms.lua @@ -131,6 +131,21 @@ flowlogic.helpers.make_neighbour_output_fixed = function(neighbours) end end +-- complementary function to the above when using non-finite mode: +-- removes water sources from neighbor positions when the output is "off" due to lack of pressure. +flowlogic.helpers.make_neighbour_cleanup_fixed = function(neighbours) + return function(pos, node, currentpressure) + -- FIXME - this would indiscriminately take blocks while under-pressure, not just one time? + for _, offset in pairs(neighbours) do + local npos = vector.add(pos, offset) + local name = minetest.get_node(npos).name + if (name == "default:water_source") then + minetest.remove_node(pos) + end + end + end +end + flowlogic.run_output = function(pos, node, threshold, outputfn) -- cgit v1.2.3