summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorthetaepsilon-gamedev <thetaepsilon-gamedev@noreply.users.github.com>2017-10-16 23:18:00 +0100
committerthetaepsilon-gamedev <thetaepsilon-gamedev@noreply.users.github.com>2017-10-16 23:18:00 +0100
commite41167813ba15344e56a291f2cc03706cb62590e (patch)
tree12d730cff69301735e483eaa558dd7eade7a0255
parent0e74978a73578d15fb75ed1d6948581ddf970d9c (diff)
downloadpipeworks-e41167813ba15344e56a291f2cc03706cb62590e.tar
pipeworks-e41167813ba15344e56a291f2cc03706cb62590e.tar.gz
pipeworks-e41167813ba15344e56a291f2cc03706cb62590e.tar.bz2
pipeworks-e41167813ba15344e56a291f2cc03706cb62590e.tar.xz
pipeworks-e41167813ba15344e56a291f2cc03706cb62590e.zip
new flow logic: flowable node registry: add directional flow type class
-rw-r--r--new_flow_logic/flowable_node_registry.lua8
-rw-r--r--new_flow_logic/flowable_node_registry_install.lua16
2 files changed, 21 insertions, 3 deletions
diff --git a/new_flow_logic/flowable_node_registry.lua b/new_flow_logic/flowable_node_registry.lua
index 2523803..c60a39e 100644
--- a/new_flow_logic/flowable_node_registry.lua
+++ b/new_flow_logic/flowable_node_registry.lua
@@ -17,6 +17,14 @@ pipeworks.flowables.list.all = {}
pipeworks.flowables.list.simple = {}
pipeworks.flowables.list.simple_nodenames = {}
+-- directional flowables - can only flow on certain sides
+-- format per entry is a table with the following fields:
+-- neighbourfn: function(node),
+-- 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
+pipeworks.flowables.list.directional = {}
+
-- simple intakes - try to absorb any adjacent water nodes
pipeworks.flowables.inputs = {}
pipeworks.flowables.inputs.list = {}
diff --git a/new_flow_logic/flowable_node_registry_install.lua b/new_flow_logic/flowable_node_registry_install.lua
index c8f6889..a49c31a 100644
--- a/new_flow_logic/flowable_node_registry_install.lua
+++ b/new_flow_logic/flowable_node_registry_install.lua
@@ -20,6 +20,9 @@ local insertbase = function(nodename)
if checkexists(nodename) then error("pipeworks.flowables duplicate registration!") end
pipeworks.flowables.list.all[nodename] = true
-- table.insert(pipeworks.flowables.list.nodenames, nodename)
+ if pipeworks.toggles.pressure_logic then
+ abmregister.flowlogic(nodename)
+ end
end
local regwarning = function(kind, nodename)
@@ -35,12 +38,19 @@ register.simple = function(nodename)
insertbase(nodename)
pipeworks.flowables.list.simple[nodename] = true
table.insert(pipeworks.flowables.list.simple_nodenames, nodename)
- if pipeworks.toggles.pressure_logic then
- abmregister.flowlogic(nodename)
- end
regwarning("simple", nodename)
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)
+ insertbase(nodename)
+ pipeworks.flowables.list.directional[nodename] = { neighbourfn = neighbourfn }
+ regwarning("directional", nodename)
+end
+
+
+
local checkbase = function(nodename)
if not checkexists(nodename) then error("pipeworks.flowables node doesn't exist as a flowable!") end
end