diff options
author | thetaepsilon-gamedev <thetaepsilon-gamedev@noreply.users.github.com> | 2017-10-07 22:35:08 +0100 |
---|---|---|
committer | thetaepsilon-gamedev <thetaepsilon-gamedev@noreply.users.github.com> | 2017-10-07 22:35:08 +0100 |
commit | f94c93bb59fa151ee90932f53afb82ac6f3aae15 (patch) | |
tree | 5a226f85ef91fffdebaae78a9fceaeecf804e476 /new_flow_logic | |
parent | d4346919bcb4d2e0c692448bc0a652d55c0fa2a9 (diff) | |
download | pipeworks-f94c93bb59fa151ee90932f53afb82ac6f3aae15.tar pipeworks-f94c93bb59fa151ee90932f53afb82ac6f3aae15.tar.gz pipeworks-f94c93bb59fa151ee90932f53afb82ac6f3aae15.tar.bz2 pipeworks-f94c93bb59fa151ee90932f53afb82ac6f3aae15.tar.xz pipeworks-f94c93bb59fa151ee90932f53afb82ac6f3aae15.zip |
new flow logic: abms.lua: implement non-finite mode cleanupfn invocation in run_output()
Diffstat (limited to 'new_flow_logic')
-rw-r--r-- | new_flow_logic/abms.lua | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/new_flow_logic/abms.lua b/new_flow_logic/abms.lua index babd14e..9197d17 100644 --- a/new_flow_logic/abms.lua +++ b/new_flow_logic/abms.lua @@ -224,11 +224,16 @@ flowlogic.run_output = function(pos, node, currentpressure, oldpressure, outputd local upper = outputdef.upper local lower = outputdef.lower local result = currentpressure - if currentpressure > lower then + local threshold = nil + if finitemode then threshold = lower else threshold = upper end + if currentpressure > threshold then local takenpressure = outputdef.outputfn(pos, node, currentpressure, finitemode) local newpressure = currentpressure - takenpressure if newpressure < 0 then newpressure = 0 end result = newpressure end + if (not finitemode) and (currentpressure < lower) and (oldpressure > lower) then + outputdef.cleanupfn(pos, node, currentpressure) + end return result end |