From 9abdeb3d626c702c044d6d621bdea6c43dbd6647 Mon Sep 17 00:00:00 2001 From: thetaepsilon-gamedev Date: Sun, 1 Oct 2017 20:12:19 +0100 Subject: [PATCH] new flow logic: abms.lua: use flowable nodes registry to determine viable neighbours --- new_flow_logic/abms.lua | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/new_flow_logic/abms.lua b/new_flow_logic/abms.lua index 640493a..66349e9 100644 --- a/new_flow_logic/abms.lua +++ b/new_flow_logic/abms.lua @@ -49,8 +49,9 @@ flowlogic.check_for_liquids_v2 = check_for_liquids_v2 +--local formatvec = function(vec) local sep="," return "("..tostring(vec.x)..sep..tostring(vec.y)..sep..tostring(vec.z)..")" end + local label_pressure = "pipeworks.water_pressure" -local label_haspressure = "pipeworks.is_pressure_node" flowlogic.balance_pressure = function(pos, node) -- debuglog("balance_pressure() "..node.name.." at "..pos.x.." "..pos.y.." "..pos.z) -- check the pressure of all nearby nodes, and average it out. @@ -60,16 +61,19 @@ flowlogic.balance_pressure = function(pos, node) -- unconditionally include self in nodes to average over local meta = minetest.get_meta(pos) local currentpressure = meta:get_float(label_pressure) - meta:set_int(label_haspressure, 1) local connections = { meta } local totalv = currentpressure local totalc = 1 -- then handle neighbours, but if not a pressure node don't consider them at all for _, npos in ipairs(make_coords_offsets(pos, false)) do + local nodename = minetest.get_node(npos).name local neighbour = minetest.get_meta(npos) - local haspressure = (neighbour:get_int(label_haspressure) ~= 0) + -- for now, just check if it's in the simple table. + -- TODO: the "can flow from" logic in flowable_node_registry.lua + local haspressure = (pipeworks.flowables.list.simple[nodename]) if haspressure then + --pipeworks.logger("balance_pressure @ "..formatvec(pos).." "..nodename.." "..formatvec(npos).." added to neighbour set") local n = neighbour:get_float(label_pressure) table.insert(connections, neighbour) totalv = totalv + n