Update exportTask.lua
Fleshed out the exportItems function which was blindly firing items into full chests. Made it a little more sensitive, slight increase in average processing time, but no more erroneous hits to export causing perf issues.
This commit is contained in:
@@ -69,10 +69,25 @@ function ExportTask:cycle(context)
|
|||||||
for key in pairs(entry.filter) do
|
for key in pairs(entry.filter) do
|
||||||
local items = Milo:getMatches(itemDB:splitKey(key), entry)
|
local items = Milo:getMatches(itemDB:splitKey(key), entry)
|
||||||
for _,item in pairs(items) do
|
for _,item in pairs(items) do
|
||||||
if node.adapter.size() ~= Util.size(node.adapter.list()) and context.storage:export(node, nil, item.count, item) == 0 then
|
node.cacheList = node.adapter.list()
|
||||||
-- TODO: really shouldn't break here as there may be room in other slots (probably not)
|
if node.adapter.size() ~= Util.size(node.cacheList) then
|
||||||
-- leaving for now for performance reasons
|
-- Here we have a storage which has at least 1 unpopulated slot, we can fire'n'forget into this
|
||||||
break
|
if context.storage:export(node, nil, item.count, item) == 0 then
|
||||||
|
-- TODO: really shouldn't break here as there may be room in other slots
|
||||||
|
-- leaving for now for performance reasons
|
||||||
|
break
|
||||||
|
end
|
||||||
|
else
|
||||||
|
-- Here we have a storage with all slots occupied, sort through and find open spaces
|
||||||
|
for iNum,_ in ipairs(node.cacheList) do
|
||||||
|
local slot = node.adapter.getItemMeta(iNum)
|
||||||
|
if (slot.name == filterItem.name and slot.count ~= slot.maxCount and
|
||||||
|
(entry.ignoreDamage or slot.damage == filterItem.damage) and
|
||||||
|
(entry.ignoreNbtHash or slot.nbtHash == filterItem.nbtHash)) then
|
||||||
|
-- We found a slot that matches, and is not full, let's export to it!
|
||||||
|
context.storage:export(node, iNum, slot.maxCount - slot.count, item)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user