Commit 1daad7e6 authored by Fedja Beader's avatar Fedja Beader
Browse files

invnet: prevent items being moved back&forth between chests

parent f9713069
......@@ -69,11 +69,12 @@ local function invnet_setup_item_move()
-- Pick a machine
local machines = invnet.machines
local machine = nil
local machine_index = nil
for _ = 1,100 do
local m_index = math.random(1, #machines)
machine = machines[m_index]
l:debug("Testing machine " .. m_index)
machine_index = math.random(1, #machines)
machine = machines[machine_index]
l:debug("Testing machine " .. machine_index)
if machine.recipe then -- skip chests
break
end
......@@ -96,7 +97,13 @@ local function invnet_setup_item_move()
for item_name,count in pairs(machine.recipe) do
local from = ItemLocations:new()
for _,src_machine in pairs(machines) do
from:collect(src_machine.pos, src_machine.output_list_name, item_name)
-- Prevent items being moved back and forth if there are multiple chests registered
-- as an output for this item. If this machine has ilist==olist, then do not take
-- items from nodes that have ilist==olist
if machine.output_list_name ~= machine.input_list_name
or src_machine.output_list_name ~= src_machine.input_list_name then
from:collect(src_machine.pos, src_machine.output_list_name, item_name)
end
end
from:sort_by_count_dsc() -- larger stacks first
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment