mirror of
https://github.com/mt-mods/pipeworks.git
synced 2024-12-28 03:40:25 +01:00
new flow logic: abms.lua: use directional callback function for direcional nodes to obtain neighbour list
This commit is contained in:
parent
e41167813b
commit
fd978204dd
@ -23,6 +23,16 @@ local make_coords_offsets = function(pos, include_base)
|
|||||||
return coords
|
return coords
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- create positions from list of offsets
|
||||||
|
-- see in use of directional flow logic below
|
||||||
|
local apply_coords_offsets = function(pos, offsets)
|
||||||
|
local result = {}
|
||||||
|
for index, offset in ipairs(offsets) do
|
||||||
|
table.insert(result, vector.add(pos, offset))
|
||||||
|
end
|
||||||
|
return result
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
-- local debuglog = function(msg) print("## "..msg) end
|
-- local debuglog = function(msg) print("## "..msg) end
|
||||||
@ -138,6 +148,13 @@ flowlogic.balance_pressure = function(pos, node, currentpressure)
|
|||||||
local candidates = {}
|
local candidates = {}
|
||||||
if pipeworks.flowables.list.simple[node.name] then
|
if pipeworks.flowables.list.simple[node.name] then
|
||||||
candidates = make_coords_offsets(pos, false)
|
candidates = make_coords_offsets(pos, false)
|
||||||
|
else
|
||||||
|
-- directional flowables: call the callback to get the list
|
||||||
|
local directional = pipeworks.flowables.list.directional[node.name]
|
||||||
|
if directional then
|
||||||
|
local offsets = directional.neighbourfn(node)
|
||||||
|
candidates = apply_coords_offsets(pos, offsets)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- then handle neighbours, but if not a pressure node don't consider them at all
|
-- then handle neighbours, but if not a pressure node don't consider them at all
|
||||||
|
Loading…
Reference in New Issue
Block a user