diff options
author | thetaepsilon-gamedev <thetaepsilon-gamedev@noreply.users.github.com> | 2017-10-08 11:32:08 +0100 |
---|---|---|
committer | thetaepsilon-gamedev <thetaepsilon-gamedev@noreply.users.github.com> | 2017-10-08 11:32:08 +0100 |
commit | 6a25e56336f98be7f91d328d6a75674450aa46a4 (patch) | |
tree | 9b83bc12d99ee3fa81368124af285d613cd9e61b /new_flow_logic | |
parent | f94c93bb59fa151ee90932f53afb82ac6f3aae15 (diff) | |
download | pipeworks-6a25e56336f98be7f91d328d6a75674450aa46a4.tar pipeworks-6a25e56336f98be7f91d328d6a75674450aa46a4.tar.gz pipeworks-6a25e56336f98be7f91d328d6a75674450aa46a4.tar.bz2 pipeworks-6a25e56336f98be7f91d328d6a75674450aa46a4.tar.xz pipeworks-6a25e56336f98be7f91d328d6a75674450aa46a4.zip |
new flow logic: algorithmic and value tuning for non-finite mode
Diffstat (limited to 'new_flow_logic')
-rw-r--r-- | new_flow_logic/abms.lua | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/new_flow_logic/abms.lua b/new_flow_logic/abms.lua index 9197d17..e83d50e 100644 --- a/new_flow_logic/abms.lua +++ b/new_flow_logic/abms.lua @@ -202,12 +202,13 @@ end -- 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? + --pipeworks.logger("neighbour_cleanup_fixed@"..formatvec(pos)) 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) + --pipeworks.logger("neighbour_cleanup_fixed removing "..formatvec(npos)) + minetest.remove_node(npos) end end end @@ -221,6 +222,7 @@ flowlogic.run_output = function(pos, node, currentpressure, oldpressure, outputd -- the outputfn is provided the current pressure and returns the pressure "taken". -- as an example, using this with the above spigot function, -- the spigot function tries to output a water source if it will fit in the world. + --pipeworks.logger("flowlogic.run_output() pos "..formatvec(pos).." old -> currentpressure "..tostring(oldpressure).." "..tostring(currentpressure).." finitemode "..tostring(finitemode)) local upper = outputdef.upper local lower = outputdef.lower local result = currentpressure @@ -232,7 +234,8 @@ flowlogic.run_output = function(pos, node, currentpressure, oldpressure, outputd if newpressure < 0 then newpressure = 0 end result = newpressure end - if (not finitemode) and (currentpressure < lower) and (oldpressure > lower) then + if (not finitemode) and (currentpressure < lower) and (oldpressure < lower) then + --pipeworks.logger("flowlogic.run_output() invoking cleanup currentpressure="..tostring(currentpressure)) outputdef.cleanupfn(pos, node, currentpressure) end return result |