new flow logic: abms.lua: don't unpack outputdef variables in flowlogic.run(), leave to flowlogic.run_output()

This commit is contained in:
thetaepsilon-gamedev 2017-10-07 21:44:33 +01:00
parent ea92bfe4d3
commit 187e755aa5

View File

@ -93,15 +93,13 @@ flowlogic.run = function(pos, node)
currentpressure = flowlogic.balance_pressure(pos, node, currentpressure) currentpressure = flowlogic.balance_pressure(pos, node, currentpressure)
-- if node is an output: run output phase -- if node is an output: run output phase
local output = pipeworks.flowables.outputs.list[nodename] local outputdef = pipeworks.flowables.outputs.list[nodename]
if output then if outputdef then
currentpressure = flowlogic.run_output( currentpressure = flowlogic.run_output(
pos, pos,
node, node,
currentpressure, currentpressure,
output.upper, outputdef)
output.lower,
output.outputfn)
end end
-- set the new pressure -- set the new pressure
@ -204,15 +202,17 @@ end
flowlogic.run_output = function(pos, node, currentpressure, upper, lower, outputfn) flowlogic.run_output = function(pos, node, currentpressure, outputdef)
-- processing step for water output devices. -- processing step for water output devices.
-- takes care of checking a minimum pressure value and updating the resulting pressure level -- takes care of checking a minimum pressure value and updating the resulting pressure level
-- the outputfn is provided the current pressure and returns the pressure "taken". -- the outputfn is provided the current pressure and returns the pressure "taken".
-- as an example, using this with the above spigot function, -- 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. -- the spigot function tries to output a water source if it will fit in the world.
local upper = outputdef.upper
local lower = outputdef.lower
local result = currentpressure local result = currentpressure
if currentpressure > lower then if currentpressure > lower then
local takenpressure = outputfn(pos, node, currentpressure) local takenpressure = outputdef.outputfn(pos, node, currentpressure)
local newpressure = currentpressure - takenpressure local newpressure = currentpressure - takenpressure
if newpressure < 0 then newpressure = 0 end if newpressure < 0 then newpressure = 0 end
result = newpressure result = newpressure