diff options
author | thetaepsilon-gamedev <thetaepsilon-gamedev@noreply.users.github.com> | 2017-09-30 23:42:26 +0100 |
---|---|---|
committer | thetaepsilon-gamedev <thetaepsilon-gamedev@noreply.users.github.com> | 2017-09-30 23:42:26 +0100 |
commit | c3627551b091d27819c242da204ed1e9dd8f15f0 (patch) | |
tree | fb51d5e91b5a6357327266b00f466881b9be1f60 /new_flow_logic/register_local_pipes.lua | |
parent | d69941a0ae763d6681ede2185ad88e25b11fead5 (diff) |
move all current new_flow_logic code to dedicated sub-directory
Diffstat (limited to 'new_flow_logic/register_local_pipes.lua')
-rw-r--r-- | new_flow_logic/register_local_pipes.lua | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/new_flow_logic/register_local_pipes.lua b/new_flow_logic/register_local_pipes.lua new file mode 100644 index 0000000..6fe8b7e --- /dev/null +++ b/new_flow_logic/register_local_pipes.lua @@ -0,0 +1,53 @@ +-- conditional registration of pipe nodes for the new pipe logic, depending on enable flags. +-- otherwise register_flow_logic.lua would be attempting to register ABMs for non-existant nodes. +-- written 2017 by thetaepsilon + + + +-- global values and thresholds for water behaviour +-- TODO: add some way of setting this per-world +local thresholds = {} +-- limit on pump pressure - will not absorb more than can be taken +thresholds.pump_pressure = 2 + + + +local pipes_full_nodenames = pipeworks.pipes_full_nodenames +local pipes_empty_nodenames = pipeworks.pipes_empty_nodenames + +local register = pipeworks.flowables.register +local abmregister = pipeworks.flowlogic.abmregister + + + +-- FIXME: DRY principle for names, move this to devices.lua? +-- FIXME: all devices still considered simple +local pump_on = "pipeworks:pump_on" +local pump_off = "pipeworks:pump_off" +local spigot_off = "pipeworks:spigot" +local spigot_on = "pipeworks:spigot_pouring" + +if pipeworks.enable_pipes then + for _, pipe in ipairs(pipes_full_nodenames) do + register.simple(pipe) + abmregister.balance(pipe) + end + for _, pipe in ipairs(pipes_empty_nodenames) do + register.simple(pipe) + abmregister.balance(pipe) + end + + if pipeworks.enable_pipe_devices then + register.simple(pump_off) + register.simple(pump_on) + register.simple(spigot_on) + register.simple(spigot_off) + abmregister.balance(pump_off) + abmregister.balance(pump_on) + abmregister.balance(spigot_on) + abmregister.balance(spigot_off) + + register.intake_simple(pump_on, thresholds.pump_pressure) + abmregister.input(pump_on, thresholds.pump_pressure) + end +end |