milo wip
This commit is contained in:
@@ -14,22 +14,30 @@ function ExportTask:cycle(context)
|
||||
local machine = device[target]
|
||||
if machine and machine.getItemMeta then
|
||||
for _, entry in pairs(v.exports) do
|
||||
local slot = machine.getItemMeta(entry.slot) or { count = 0 }
|
||||
local item = itemDB:splitKey(entry.name)
|
||||
local slotNo = type(entry.slot) == 'number' and entry.slot or nil -- '*' indicates any slot
|
||||
|
||||
-- is something else is in this slot
|
||||
if not slot.name or slot.name == item.name then
|
||||
local maxCount = slot.maxCount or itemDB:getMaxCount(item)
|
||||
local count = maxCount - slot.count
|
||||
local slot = (slotNo and machine.getItemMeta(slotNo)) or { count = 0 }
|
||||
for key in pairs(entry.filter) do
|
||||
local item = itemDB:splitKey(key)
|
||||
|
||||
if count > 0 then
|
||||
item = Milo:getItemWithQty(item)
|
||||
if item and count > 0 then
|
||||
context.storage:export(
|
||||
target,
|
||||
entry.slot,
|
||||
math.min(count, item.count),
|
||||
item)
|
||||
-- is something else is in this slot
|
||||
if not slot.name or slot.name == item.name then
|
||||
local maxCount = slot.maxCount or itemDB:getMaxCount(item)
|
||||
local count = maxCount - slot.count
|
||||
if not slotNo then
|
||||
-- TODO: should we just execute export -
|
||||
-- or scan all slots for space ??
|
||||
count = machine.size() * maxCount - slot.count
|
||||
end
|
||||
if count > 0 then
|
||||
item = Milo:getItemWithQty(item)
|
||||
if item and count > 0 then
|
||||
context.storage:export(
|
||||
target,
|
||||
slotNo,
|
||||
math.min(count, item.count),
|
||||
item)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user