summaryrefslogtreecommitdiff
path: root/pressure_logic
diff options
context:
space:
mode:
authorthetaepsilon-gamedev <thetaepsilon-gamedev@noreply.users.github.com>2017-10-19 12:28:33 +0100
committerthetaepsilon-gamedev <thetaepsilon-gamedev@noreply.users.github.com>2017-10-19 12:28:33 +0100
commit0913098a9de262050ccde0bdd221dd1a12d1a785 (patch)
tree7840cf29fc9f9488becafdf419141e2b7ff2dd52 /pressure_logic
parentefcec7bdcee9d4cb955ffb6bcc1cadaf342889ae (diff)
downloadpipeworks-0913098a9de262050ccde0bdd221dd1a12d1a785.tar
pipeworks-0913098a9de262050ccde0bdd221dd1a12d1a785.tar.gz
pipeworks-0913098a9de262050ccde0bdd221dd1a12d1a785.tar.bz2
pipeworks-0913098a9de262050ccde0bdd221dd1a12d1a785.tar.xz
pipeworks-0913098a9de262050ccde0bdd221dd1a12d1a785.zip
pressure logic: add horizontally-rotating directional flowable helper
Diffstat (limited to 'pressure_logic')
-rw-r--r--pressure_logic/flowable_node_registry_install.lua37
1 files changed, 37 insertions, 0 deletions
diff --git a/pressure_logic/flowable_node_registry_install.lua b/pressure_logic/flowable_node_registry_install.lua
index d8f945b..7b14fd3 100644
--- a/pressure_logic/flowable_node_registry_install.lua
+++ b/pressure_logic/flowable_node_registry_install.lua
@@ -66,6 +66,43 @@ register.directional_vertical_fixed = function(nodename, topside)
register.directional(nodename, neighbourfn, directionfn)
end
+-- register a node as a directional flowable whose accepting sides depends upon param2 rotation.
+-- used for entry panels, valves, flow sensors and spigots,
+-- whose facing axis is always upwards and can only rotate horizontally.
+local iseastwest = function(node)
+ local data = node.param2
+ local rotation = data % 4
+ -- rotation 0 and 2 is the same axis, as is 1 and 3.
+ -- 0-3 starts at north and proceeds clockwise.
+ local axis = rotation % 2
+ --pipeworks.logger("iseastwest() rotation="..tostring(rotation).." axis="..tostring(axis))
+ return (axis == 1)
+end
+register.directional_horizonal_rotate = function(nodename)
+ local north = {x= 0,y= 0,z= 1}
+ local south = {x= 0,y= 0,z=-1}
+ local east = {x= 1,y= 0,z= 0}
+ local west = {x=-1,y= 0,z= 0}
+ local neighbourfn = function(node)
+ if iseastwest(node) then
+ return { east, west }
+ else
+ return { north, south }
+ end
+ end
+ local directionfn = function(node, direction)
+ local result = false
+ if iseastwest(node) then
+ --pipeworks.logger("horizontal rotate directionfn() eastwest=true")
+ result = vector.equals(direction, east) or vector.equals(direction, west)
+ else
+ result = vector.equals(direction, north) or vector.equals(direction, south)
+ end
+ return result
+ end
+ register.directional(nodename, neighbourfn, directionfn)
+end
+
local checkbase = function(nodename)