summaryrefslogtreecommitdiff
path: root/flowable_nodes_add_pipes.lua
diff options
context:
space:
mode:
authorthetaepsilon-gamedev <thetaepsilon-gamedev@noreply.users.github.com>2017-09-30 20:16:00 +0100
committerthetaepsilon-gamedev <thetaepsilon-gamedev@noreply.users.github.com>2017-09-30 21:27:50 +0100
commit40eeaac2ecb25dbc55f7315342e74723d6248534 (patch)
treec01da4e9ac67d84b372a69ef3b781020afb68af5 /flowable_nodes_add_pipes.lua
parent10221c6c153e4d20bf1d289fe218d29477400a4d (diff)
downloadpipeworks-40eeaac2ecb25dbc55f7315342e74723d6248534.tar
pipeworks-40eeaac2ecb25dbc55f7315342e74723d6248534.tar.gz
pipeworks-40eeaac2ecb25dbc55f7315342e74723d6248534.tar.bz2
pipeworks-40eeaac2ecb25dbc55f7315342e74723d6248534.tar.xz
pipeworks-40eeaac2ecb25dbc55f7315342e74723d6248534.zip
internal refactoring of flowable node registration in preparation for enhanced flow checking logic
Diffstat (limited to 'flowable_nodes_add_pipes.lua')
-rw-r--r--flowable_nodes_add_pipes.lua45
1 files changed, 45 insertions, 0 deletions
diff --git a/flowable_nodes_add_pipes.lua b/flowable_nodes_add_pipes.lua
new file mode 100644
index 0000000..e681619
--- /dev/null
+++ b/flowable_nodes_add_pipes.lua
@@ -0,0 +1,45 @@
+-- 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
+
+
+
+-- 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)
+ end
+ for _, pipe in ipairs(pipes_empty_nodenames) do
+ register.simple(pipe)
+ end
+
+ if pipeworks.enable_pipe_devices then
+ register.simple(pump_off)
+ register.simple(pump_on)
+ register.simple(spigot_on)
+ register.simple(spigot_off)
+
+ register.intake_simple(pump_on, thresholds.pump_pressure)
+ end
+end