diff options
author | thetaepsilon-gamedev <thetaepsilon-gamedev@noreply.users.github.com> | 2017-10-07 13:24:46 +0100 |
---|---|---|
committer | thetaepsilon-gamedev <thetaepsilon-gamedev@noreply.users.github.com> | 2017-10-07 13:24:46 +0100 |
commit | 6f90ee0875dd0f89f460b6ae75acac708a63cb4c (patch) | |
tree | 4ea4910cc19d1367efcabf1b0042cda2bc041770 /new_flow_logic | |
parent | 31a67cf4f98f0c9850998799956063401efceef5 (diff) | |
download | pipeworks-6f90ee0875dd0f89f460b6ae75acac708a63cb4c.tar pipeworks-6f90ee0875dd0f89f460b6ae75acac708a63cb4c.tar.gz pipeworks-6f90ee0875dd0f89f460b6ae75acac708a63cb4c.tar.bz2 pipeworks-6f90ee0875dd0f89f460b6ae75acac708a63cb4c.tar.xz pipeworks-6f90ee0875dd0f89f460b6ae75acac708a63cb4c.zip |
new flow logic: abms.lua: add companion cleaner helper for neighbour output
Diffstat (limited to 'new_flow_logic')
-rw-r--r-- | new_flow_logic/abms.lua | 15 |
1 files changed, 15 insertions, 0 deletions
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) |