more rework on exportTask

This commit is contained in:
kepler155c@gmail.com
2020-05-18 21:57:04 -06:00
parent 72a85f1a4a
commit 503a340035

View File

@@ -69,20 +69,17 @@ function ExportTask:cycle(context)
end end
local function exportItems() local function exportItems()
local function isPossible(key) local function canExport(item)
local filterItem = itemDB:get(key)
if not node.adapter.__size then if not node.adapter.__size then
node.adapter.__size = node.adapter.size() node.adapter.__size = node.adapter.size()
end end
-- note that this does not guarantee a match - as
-- we don't have full meta of item in slot
for i = 1, node.adapter.__size do for i = 1, node.adapter.__size do
local slot = slots[i] local slot = slots[i]
if (not slot or slot.name == filterItem.name and if (not slot or slot.name == item.name and
(entry.ignoreDamage or slot.damage == filterItem.damage) and (entry.ignoreDamage or slot.damage == item.damage) and
slot.count < filterItem.maxCount) then (entry.ignoreNbtHash or slot.nbtHash == item.nbtHash) and
slot.count < item.maxCount) then
return true return true
end end
@@ -93,18 +90,14 @@ function ExportTask:cycle(context)
if not slots then if not slots then
slots = node.adapter.list() slots = node.adapter.list()
end end
if isPossible(key) then 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 canExport(item) then
if context.storage:export(node, nil, item.count, item) == 0 then 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 break
else
-- refresh the slots
slots = nil
end end
-- refresh the slots
slots = nil
end end
end end
end end