diff options
author | thetaepsilon-gamedev <thetaepsilon-gamedev@noreply.users.github.com> | 2017-10-01 20:12:19 +0100 |
---|---|---|
committer | thetaepsilon-gamedev <thetaepsilon-gamedev@noreply.users.github.com> | 2017-10-01 20:12:19 +0100 |
commit | 9abdeb3d626c702c044d6d621bdea6c43dbd6647 (patch) | |
tree | 49f89df036129e5a8aff7c1e1d30310cc6e4f643 | |
parent | df3d54f58a7b00880f6631e309fba08fb769cd33 (diff) | |
download | pipeworks-9abdeb3d626c702c044d6d621bdea6c43dbd6647.tar pipeworks-9abdeb3d626c702c044d6d621bdea6c43dbd6647.tar.gz pipeworks-9abdeb3d626c702c044d6d621bdea6c43dbd6647.tar.bz2 pipeworks-9abdeb3d626c702c044d6d621bdea6c43dbd6647.tar.xz pipeworks-9abdeb3d626c702c044d6d621bdea6c43dbd6647.zip |
new flow logic: abms.lua: use flowable nodes registry to determine viable neighbours
-rw-r--r-- | new_flow_logic/abms.lua | 10 |
1 files 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 |