diff options
| author | thetaepsilon-gamedev <thetaepsilon-gamedev@noreply.users.github.com> | 2017-10-16 23:27:04 +0100 | 
|---|---|---|
| committer | thetaepsilon-gamedev <thetaepsilon-gamedev@noreply.users.github.com> | 2017-10-16 23:27:04 +0100 | 
| commit | fd978204dd5c72d350ba0d31ec43c628c46599f3 (patch) | |
| tree | 8d602597e4c947b2a4dfbb3ccb05ac37f3f72f6c | |
| parent | e41167813ba15344e56a291f2cc03706cb62590e (diff) | |
new flow logic: abms.lua: use directional callback function for direcional nodes to obtain neighbour list
| -rw-r--r-- | new_flow_logic/abms.lua | 17 | 
1 files changed, 17 insertions, 0 deletions
| diff --git a/new_flow_logic/abms.lua b/new_flow_logic/abms.lua index 0b0b799..e5e2e6e 100644 --- a/new_flow_logic/abms.lua +++ b/new_flow_logic/abms.lua @@ -23,6 +23,16 @@ local make_coords_offsets = function(pos, include_base)  	return coords  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 @@ -138,6 +148,13 @@ flowlogic.balance_pressure = function(pos, node, currentpressure)  	local candidates = {}  	if pipeworks.flowables.list.simple[node.name] then  		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  	-- then handle neighbours, but if not a pressure node don't consider them at all | 
