From aacd5ec829e531c808881021d5fe36aeedcfc2fd Mon Sep 17 00:00:00 2001 From: thetaepsilon-gamedev Date: Tue, 17 Oct 2017 14:20:55 +0100 Subject: rename new_flow_logic subdirectory to a less ambiguous name The "new flow logic" name was supposed to indicate that it was a continuation of the old branch by the same name, but it is beginning to become clear that it's not "new" any more and it might lead to confusion with "classic mode" flow logic while that still co-exists. Explicitly name the subdirectory "pressure logic" to give a better idea of what goes in it, init.lua edited accordingly. --- pressure_logic/flowable_node_registry.lua | 56 +++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 pressure_logic/flowable_node_registry.lua (limited to 'pressure_logic/flowable_node_registry.lua') diff --git a/pressure_logic/flowable_node_registry.lua b/pressure_logic/flowable_node_registry.lua new file mode 100644 index 0000000..c60a39e --- /dev/null +++ b/pressure_logic/flowable_node_registry.lua @@ -0,0 +1,56 @@ +-- registry of flowable node behaviours in new flow logic +-- written 2017 by thetaepsilon + +-- the actual registration functions which edit these tables can be found in flowable_node_registry_install.lua +-- this is because the ABM code needs to inspect these tables, +-- but the registration code needs to reference said ABM code. +-- so those functions were split out to resolve a circular dependency. + + + +pipeworks.flowables = {} +pipeworks.flowables.list = {} +pipeworks.flowables.list.all = {} +-- pipeworks.flowables.list.nodenames = {} + +-- simple flowables - balance pressure in any direction +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 = {} +pipeworks.flowables.inputs.nodenames = {} + +-- outputs - takes pressure from pipes and update world to do something with it +pipeworks.flowables.outputs = {} +pipeworks.flowables.outputs.list = {} +-- not currently any nodenames arraylist for this one as it's not currently needed. + +-- nodes with registered node transitions +-- nodes will be switched depending on pressure level +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 -- cgit v1.2.3 From 0a4d15d26ecc33315a5d088eace532ca3e539bbb Mon Sep 17 00:00:00 2001 From: thetaepsilon-gamedev Date: Tue, 17 Oct 2017 23:14:26 +0100 Subject: pressure logic: flowable node registry: add directionfn to directional flowable entries --- pressure_logic/flowable_node_registry.lua | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) (limited to 'pressure_logic/flowable_node_registry.lua') 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 -- cgit v1.2.3