summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorthetaepsilon-gamedev <thetaepsilon-gamedev@noreply.users.github.com>2017-10-18 21:19:59 +0100
committerthetaepsilon-gamedev <thetaepsilon-gamedev@noreply.users.github.com>2017-10-18 21:20:19 +0100
commit7f7dfb79d5f81dfe09920b8c872e1a11f22bff43 (patch)
treeb3cc0a641d78b449fed5641f4b405e10d41f07c9
parent7b141fb0ea216e2ca49eb4d2246bca9f8689c5d0 (diff)
downloadpipeworks-7f7dfb79d5f81dfe09920b8c872e1a11f22bff43.tar
pipeworks-7f7dfb79d5f81dfe09920b8c872e1a11f22bff43.tar.gz
pipeworks-7f7dfb79d5f81dfe09920b8c872e1a11f22bff43.tar.bz2
pipeworks-7f7dfb79d5f81dfe09920b8c872e1a11f22bff43.tar.xz
pipeworks-7f7dfb79d5f81dfe09920b8c872e1a11f22bff43.zip
pressure logic/flowable node registry: move pump directionality code to dedicated fixed vertical helper
-rw-r--r--devices.lua8
-rw-r--r--pressure_logic/flowable_node_registry_install.lua14
2 files changed, 15 insertions, 7 deletions
diff --git a/devices.lua b/devices.lua
index d9edcad..6dd9617 100644
--- a/devices.lua
+++ b/devices.lua
@@ -165,13 +165,7 @@ for s in ipairs(states) do
})
-- FIXME: this currently assumes that pumps can only rotate around the fixed axis pointing Y+.
- -- TODO: these directionality functions should be behind a helper so the fountainhead can use something similar.
- local upwards = {x=0,y=1,z=0}
- local neighbourfn = function(node) return { upwards } end
- local directionfn = function(node, direction)
- return vector.equals(direction, upwards)
- end
- new_flow_logic_register.directional(pumpname, neighbourfn, directionfn)
+ new_flow_logic_register.directional_vertical_fixed(pumpname, true)
local pump_drive = 4
if states[s] ~= "off" then
new_flow_logic_register.intake_simple(pumpname, pump_drive)
diff --git a/pressure_logic/flowable_node_registry_install.lua b/pressure_logic/flowable_node_registry_install.lua
index 3cd9c4d..d8f945b 100644
--- a/pressure_logic/flowable_node_registry_install.lua
+++ b/pressure_logic/flowable_node_registry_install.lua
@@ -52,6 +52,20 @@ register.directional = function(nodename, neighbourfn, directionfn)
regwarning("directional", nodename)
end
+-- register a node as a directional flowable that can only flow through either the top or bottom side.
+-- used for fountainheads (bottom side) and pumps (top side).
+-- this is in world terms, not facedir relative!
+register.directional_vertical_fixed = function(nodename, topside)
+ local y
+ if topside then y = 1 else y = -1 end
+ local side = { x=0, y=y, z=0 }
+ local neighbourfn = function(node) return { side } end
+ local directionfn = function(node, direction)
+ return vector.equals(direction, side)
+ end
+ register.directional(nodename, neighbourfn, directionfn)
+end
+
local checkbase = function(nodename)