From 187e755aa5d7f4ddbc68cc2c4d8494051321a3cd Mon Sep 17 00:00:00 2001 From: thetaepsilon-gamedev Date: Sat, 7 Oct 2017 21:44:33 +0100 Subject: new flow logic: abms.lua: don't unpack outputdef variables in flowlogic.run(), leave to flowlogic.run_output() --- new_flow_logic/abms.lua | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'new_flow_logic') diff --git a/new_flow_logic/abms.lua b/new_flow_logic/abms.lua index eb551d8..6fee744 100644 --- a/new_flow_logic/abms.lua +++ b/new_flow_logic/abms.lua @@ -93,15 +93,13 @@ flowlogic.run = function(pos, node) currentpressure = flowlogic.balance_pressure(pos, node, currentpressure) -- if node is an output: run output phase - local output = pipeworks.flowables.outputs.list[nodename] - if output then + local outputdef = pipeworks.flowables.outputs.list[nodename] + if outputdef then currentpressure = flowlogic.run_output( pos, node, currentpressure, - output.upper, - output.lower, - output.outputfn) + outputdef) end -- 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. -- 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". -- 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. + local upper = outputdef.upper + local lower = outputdef.lower local result = currentpressure if currentpressure > lower then - local takenpressure = outputfn(pos, node, currentpressure) + local takenpressure = outputdef.outputfn(pos, node, currentpressure) local newpressure = currentpressure - takenpressure if newpressure < 0 then newpressure = 0 end result = newpressure -- cgit v1.2.3