summaryrefslogtreecommitdiff
path: root/new_flow_logic
diff options
context:
space:
mode:
authorthetaepsilon-gamedev <thetaepsilon-gamedev@noreply.users.github.com>2017-10-07 21:44:33 +0100
committerthetaepsilon-gamedev <thetaepsilon-gamedev@noreply.users.github.com>2017-10-07 21:44:33 +0100
commit187e755aa5d7f4ddbc68cc2c4d8494051321a3cd (patch)
tree7b44d6b3d28fcc98fbd6d3858834a4f48a829627 /new_flow_logic
parentea92bfe4d321e11955c360fad527e08196fa5841 (diff)
downloadpipeworks-187e755aa5d7f4ddbc68cc2c4d8494051321a3cd.tar
pipeworks-187e755aa5d7f4ddbc68cc2c4d8494051321a3cd.tar.gz
pipeworks-187e755aa5d7f4ddbc68cc2c4d8494051321a3cd.tar.bz2
pipeworks-187e755aa5d7f4ddbc68cc2c4d8494051321a3cd.tar.xz
pipeworks-187e755aa5d7f4ddbc68cc2c4d8494051321a3cd.zip
new flow logic: abms.lua: don't unpack outputdef variables in flowlogic.run(), leave to flowlogic.run_output()
Diffstat (limited to 'new_flow_logic')
-rw-r--r--new_flow_logic/abms.lua14
1 files changed, 7 insertions, 7 deletions
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