milo: better perf when storage is full

This commit is contained in:
kepler155c@gmail.com
2019-04-22 15:15:27 -04:00
parent 7e092b66ee
commit 9cf630000b
3 changed files with 18 additions and 9 deletions

View File

@@ -55,7 +55,9 @@ function ImportTask:cycle(context)
return node.adapter.getItemMeta(slotNo)
end)
if item and matchesFilter(item) then
context.storage:import(node, slotNo, item.count, item)
if context.storage:import(node, slotNo, item.count, item) ~= item.count then
error('Failed to import %s', item.name)
end
end
end
@@ -72,6 +74,9 @@ function ImportTask:cycle(context)
end)
end
function tasks:onError(msg)
_G._debug('IMPORT error: ' .. msg)
end
tasks:run()
end

View File

@@ -12,16 +12,13 @@ function InputChest:cycle(context)
})
for node in context.storage:filterActive('input') do
local s, m = pcall(function()
tasks:add(function()
for slot, item in pairs(node.adapter.list()) do
tasks:add(function()
context.storage:import(node, slot, item.count, item)
end)
if context.storage:import(node, slot, item.count, item) ~= item.count then
break
end
end
end)
if not s and m then
_G._debug('INPUT error: ' .. m)
end
end
tasks:run()