This way even if a filter inserter stucks with a wrong item in its hand it won't put that item in a wagon like it happened to me. (Yes, I know about the "Locked slots" feature but it seems so overcomplicated to use it).
In control.lua after
Code: Select all
schedule.records[1] = NewScheduleRecord(depot.entity.backer_name, "inactivity", depot_inactivity)
schedule.records[2] = NewScheduleRecord(from, "item_count", ">", loadingList)
schedule.records[3] = NewScheduleRecord(to, "item_count", "=", loadingList, 0)
selectedTrain.schedule = schedule
Code: Select all
if selectedTrain.cargo_wagons then
local loadingListIndex = 0
local stacksSet = 0
repeat
loadingListIndex = loadingListIndex + 1
until (#loadingList < loadingListIndex) or (#loadingList[loadingListIndex].type ~= "fluid")
for n,wagon in pairs(selectedTrain.cargo_wagons) do
local inventory = wagon.get_inventory(defines.inventory.cargo_wagon)
if inventory then
if inventory.supports_filters() then
for slotIndex=1, #inventory, 1 do
if #loadingList < loadingListIndex then
inventory.setbar(slotIndex-1)
break
else
local el = loadingList[loadingListIndex]
inventory.set_filter(slotIndex, el.name)
stacksSet = stacksSet + 1
if (el.stacks - stacksSet <= 0) then
repeat
loadingListIndex = loadingListIndex + 1
until (#loadingList < loadingListIndex) or (#loadingList[loadingListIndex].type ~= "fluid")
stacksSet = 0
end
end
end
end
end
end
end