summaryrefslogtreecommitdiff
path: root/new_flow_logic
diff options
context:
space:
mode:
authorthetaepsilon-gamedev <thetaepsilon-gamedev@noreply.users.github.com>2017-10-01 12:34:20 +0100
committerthetaepsilon-gamedev <thetaepsilon-gamedev@noreply.users.github.com>2017-10-01 12:34:20 +0100
commitf3a94fcd248df35b4afb992941a58af4cc17f446 (patch)
tree76a5b4548a16fdb13a99e85ca44f85b0c5b0dea4 /new_flow_logic
parent15b41d14f3923ce3cea8418a792f83e7763d5b00 (diff)
downloadpipeworks-f3a94fcd248df35b4afb992941a58af4cc17f446.tar
pipeworks-f3a94fcd248df35b4afb992941a58af4cc17f446.tar.gz
pipeworks-f3a94fcd248df35b4afb992941a58af4cc17f446.tar.bz2
pipeworks-f3a94fcd248df35b4afb992941a58af4cc17f446.tar.xz
pipeworks-f3a94fcd248df35b4afb992941a58af4cc17f446.zip
new flow logic: abm_register.lua: add register_abm_output routine
Diffstat (limited to 'new_flow_logic')
-rw-r--r--new_flow_logic/abm_register.lua24
1 files changed, 22 insertions, 2 deletions
diff --git a/new_flow_logic/abm_register.lua b/new_flow_logic/abm_register.lua
index 793ea83..c1b2d7d 100644
--- a/new_flow_logic/abm_register.lua
+++ b/new_flow_logic/abm_register.lua
@@ -6,7 +6,11 @@
local register = {}
pipeworks.flowlogic.abmregister = register
+local flowlogic = pipeworks.flowlogic
+-- A possible DRY violation here...
+-- DISCUSS: should it be possible later on to raise the the rate of ABMs, or lower the chance?
+-- Currently all the intervals and chances are hardcoded below.
-- register a node name for the pressure balancing ABM.
-- currently this only exists as a per-node function to allow nodes to be registered outside pipeworks.
@@ -16,7 +20,7 @@ local register_abm_balance = function(nodename)
interval = 1,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
- pipeworks.flowlogic.balance_pressure(pos, node)
+ flowlogic.balance_pressure(pos, node)
end
})
end
@@ -31,12 +35,28 @@ local register_abm_input = function(nodename, maxpressure, intakefn)
interval = 1,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
- pipeworks.flowlogic.run_input(pos, node, maxpressure, intakefn)
+ flowlogic.run_input(pos, node, maxpressure, intakefn)
end
})
end
register.input = register_abm_input
+-- register a node for the output ABM.
+-- threshold determines the minimum pressure, over which outputfn is called.
+-- outputfn is then given the current pressure, and returns the pressure relieved by the output process.
+-- outputfn is expected to update environment, nearby world etc. as appropriate for the node.
+local register_abm_output = function(nodename, threshold, outputfn)
+ minetest.register_abm({
+ nodenames = { nodename },
+ interval = 1,
+ chance = 1,
+ action = function(pos, node, active_object_count, active_object_count_wider)
+ flowlogic.run_output(pos, node, threshold, outputfn)
+ end
+ })
+end
+register.output = register_abm_output
+
-- old spigot ABM code, not yet migrated
--[[
minetest.register_abm({