summaryrefslogtreecommitdiff
path: root/pressure_logic
diff options
context:
space:
mode:
authorthetaepsilon-gamedev <thetaepsilon-gamedev@noreply.users.github.com>2017-10-17 23:14:26 +0100
committerthetaepsilon-gamedev <thetaepsilon-gamedev@noreply.users.github.com>2017-10-17 23:14:26 +0100
commit0a4d15d26ecc33315a5d088eace532ca3e539bbb (patch)
tree0172b1bc55cbf420bb5c1b0d5ebbbd6ed6f0ec89 /pressure_logic
parent909b321f3c6c866f686ae31dfc59a4a932f4d9c6 (diff)
downloadpipeworks-0a4d15d26ecc33315a5d088eace532ca3e539bbb.tar
pipeworks-0a4d15d26ecc33315a5d088eace532ca3e539bbb.tar.gz
pipeworks-0a4d15d26ecc33315a5d088eace532ca3e539bbb.tar.bz2
pipeworks-0a4d15d26ecc33315a5d088eace532ca3e539bbb.tar.xz
pipeworks-0a4d15d26ecc33315a5d088eace532ca3e539bbb.zip
pressure logic: flowable node registry: add directionfn to directional flowable entries
Diffstat (limited to 'pressure_logic')
-rw-r--r--pressure_logic/flowable_node_registry.lua23
-rw-r--r--pressure_logic/flowable_node_registry_install.lua7
2 files changed, 15 insertions, 15 deletions
diff --git a/pressure_logic/flowable_node_registry.lua b/pressure_logic/flowable_node_registry.lua
index c60a39e..6d7bf17 100644
--- a/pressure_logic/flowable_node_registry.lua
+++ b/pressure_logic/flowable_node_registry.lua
@@ -23,6 +23,16 @@ pipeworks.flowables.list.simple_nodenames = {}
-- called to determine which nodes to consider as neighbours.
-- can be used to e.g. inspect the node's param values for facedir etc.
-- returns: array of vector offsets to look for possible neighbours in
+-- directionfn: function(node, vector):
+-- can this node flow in this direction?
+-- called in the context of another node to check the matching entry returned by neighbourfn.
+-- for every offset vector returned by neighbourfn,
+-- the node at that absolute position is checked.
+-- if that node is also a directional flowable,
+-- then that node's vector is passed to that node's directionfn
+-- (inverted, so that directionfn sees a vector pointing out from it back to the origin node).
+-- if directionfn agrees that the neighbour node can currently flow in that direction,
+-- the neighbour is to participate in pressure balancing.
pipeworks.flowables.list.directional = {}
-- simple intakes - try to absorb any adjacent water nodes
@@ -41,16 +51,3 @@ pipeworks.flowables.transitions = {}
pipeworks.flowables.transitions.list = {} -- master list
pipeworks.flowables.transitions.simple = {} -- nodes that change based purely on pressure
pipeworks.flowables.transitions.mesecons = {} -- table of mesecons rules to apply on transition
-
-
-
--- checks if a given node can flow in a given direction.
--- used to implement directional devices such as pumps,
--- which only visually connect in a certain direction.
--- node is the usual name + param structure.
--- direction is an x/y/z vector of the flow direction;
--- this function answers the question "can this node flow in this direction?"
-pipeworks.flowables.flow_check = function(node, direction)
- minetest.log("warning", "pipeworks.flowables.flow_check() stub!")
- return true
-end
diff --git a/pressure_logic/flowable_node_registry_install.lua b/pressure_logic/flowable_node_registry_install.lua
index a49c31a..3cd9c4d 100644
--- a/pressure_logic/flowable_node_registry_install.lua
+++ b/pressure_logic/flowable_node_registry_install.lua
@@ -43,9 +43,12 @@ end
-- Register a node as a directional flowable:
-- has a helper function which determines which nodes to consider valid neighbours.
-register.directional = function(nodename, neighbourfn)
+register.directional = function(nodename, neighbourfn, directionfn)
insertbase(nodename)
- pipeworks.flowables.list.directional[nodename] = { neighbourfn = neighbourfn }
+ pipeworks.flowables.list.directional[nodename] = {
+ neighbourfn = neighbourfn,
+ directionfn = directionfn
+ }
regwarning("directional", nodename)
end