milo logging
This commit is contained in:
@@ -415,8 +415,8 @@ function Storage:export(target, slot, count, item)
|
|||||||
self:updateCache(adapter, item, -amount)
|
self:updateCache(adapter, item, -amount)
|
||||||
|
|
||||||
_G._debug('EXT: %s(%d): %s -> %s%s',
|
_G._debug('EXT: %s(%d): %s -> %s%s',
|
||||||
item.displayName or item.name, amount, self:_sn(adapter.name), self:_sn(target.name),
|
item.displayName or item.name, amount, self:_sn(adapter.name), self:_sn(target.name),
|
||||||
slot and string.format('[%d]', slot) or '[*]')
|
slot and string.format('[%d]', slot) or '[*]')
|
||||||
end
|
end
|
||||||
count = count - amount
|
count = count - amount
|
||||||
total = total + amount
|
total = total + amount
|
||||||
@@ -514,7 +514,7 @@ function Storage:import(source, slot, count, item)
|
|||||||
if node.lock and node.lock[key] then
|
if node.lock and node.lock[key] then
|
||||||
insert(node.adapter, item)
|
insert(node.adapter, item)
|
||||||
if count > 0 and node.void then
|
if count > 0 and node.void then
|
||||||
total = total + self:trash(source, slot, count)
|
total = total + self:trash(source, slot, count, item)
|
||||||
return total
|
return total
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -549,13 +549,16 @@ function Storage:import(source, slot, count, item)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- When importing items into a locked chest, trash any remaining items if full
|
-- When importing items into a locked chest, trash any remaining items if full
|
||||||
function Storage:trash(source, slot, count)
|
function Storage:trash(source, slot, count, item)
|
||||||
local target = Util.find(self.nodes, 'mtype', 'trashcan')
|
local target = Util.find(self.nodes, 'mtype', 'trashcan')
|
||||||
local amount = 0
|
local amount = 0
|
||||||
if target and target.adapter and target.adapter.online then
|
if target and target.adapter and target.adapter.online then
|
||||||
local s, m = pcall(function()
|
local s, m = pcall(function()
|
||||||
_G._debug('TRA: %s[%d] (%d)', self:_sn(source.name), slot, count or 64)
|
_G._debug('TRA: %s(%d): %s%s -> %s',
|
||||||
--return trashcan.adapter.pullItems(source.name, slot, count)
|
item.displayName or item.name, count, self:_sn(source.name),
|
||||||
|
slot and string.format('[%d]', slot) or '[*]', self:_sn(target.name))
|
||||||
|
|
||||||
|
--_G._debug('TRA: %s[%d] (%d)', self:_sn(source.name), slot, count or 64)
|
||||||
if isValidTransfer(source.adapter, target.name) then
|
if isValidTransfer(source.adapter, target.name) then
|
||||||
amount = source.adapter.pushItems(target.name, slot, count)
|
amount = source.adapter.pushItems(target.name, slot, count)
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -54,7 +54,10 @@ function ExportTask:cycle(context)
|
|||||||
local _, item = next(items)
|
local _, item = next(items)
|
||||||
if item then
|
if item then
|
||||||
local count = math.min(item.count, itemDB:getMaxCount(item))
|
local count = math.min(item.count, itemDB:getMaxCount(item))
|
||||||
context.storage:export(node, entry.slot, count, item)
|
if context.storage:export(node, entry.slot, count, item) ~= count then
|
||||||
|
_G._debug('EXPORTER warning: Failed to export %s(%d) %s[%d]',
|
||||||
|
node.displayName or node.name, entry.slot, item.name, count)
|
||||||
|
end
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -67,6 +70,8 @@ function ExportTask:cycle(context)
|
|||||||
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
|
-- TODO: really shouldn't break here as there may be room in other slots
|
||||||
-- leaving for now for performance reasons
|
-- leaving for now for performance reasons
|
||||||
|
_G._debug('EXPORTER warning: Failed to export %s %s[%d]',
|
||||||
|
node.displayName or node.name, item.name, item.count)
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -55,7 +55,10 @@ function ImportTask:cycle(context)
|
|||||||
return node.adapter.getItemMeta(slotNo)
|
return node.adapter.getItemMeta(slotNo)
|
||||||
end)
|
end)
|
||||||
if item and matchesFilter(item) then
|
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
|
||||||
|
_G._debug('IMPORTER warning: Failed to import %s(%d) %s[%d]',
|
||||||
|
node.displayName or node.name, slotNo, item.name, item.count)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user