milo logging

This commit is contained in:
kepler155c@gmail.com
2019-03-16 21:30:24 -04:00
parent ebd0896ee9
commit 4362a92193
6 changed files with 58 additions and 34 deletions

View File

@@ -432,7 +432,7 @@ function Storage:export(target, slot, count, item)
end
end
_G._debug('MISS: %s(%d): %s%s %s',
_G._debug('STORAGE warning: %s(%d): %s%s %s failed to export',
item.displayName or item.name, count, self:_sn(target.name),
slot and string.format('[%d]', slot) or '[*]', key)
@@ -499,8 +499,8 @@ function Storage:import(source, slot, count, item)
self:updateCache(adapter, item, amount)
_G._debug('INS: %s(%d): %s[%d] -> %s',
item.displayName or item.name, amount,
self:_sn(source.name), slot, self:_sn(adapter.name))
item.displayName or item.name, amount,
self:_sn(source.name), slot, self:_sn(adapter.name))
-- record that we have imported this item into storage during this cycle
self.activity[key] = (self.activity[key] or 0) + amount
@@ -514,8 +514,7 @@ function Storage:import(source, slot, count, item)
if node.lock and node.lock[key] then
insert(node.adapter, item)
if count > 0 and node.void then
total = total + self:trash(source, slot, count, item)
return total
return total + self:trash(source, slot, count, item)
end
end
if count <= 0 then
@@ -545,10 +544,17 @@ function Storage:import(source, slot, count, item)
end
end
if count ~= 0 then
_G._debug('STORAGE warning: %s(%d): %s -> INSERT failed',
item.displayName or item.name, count,
self:_sn(source.name))
end
return total
end
-- When importing items into a locked chest, trash any remaining items if full
-- TODO: use all available trashcans
function Storage:trash(source, slot, count, item)
local target = Util.find(self.nodes, 'mtype', 'trashcan')
local amount = 0
@@ -569,6 +575,13 @@ function Storage:trash(source, slot, count, item)
_G._debug(m)
end
end
if amount ~= count then
_G._debug('STORAGE warning: %s(%d): %s -> TRASH failed',
item.displayName or item.name, count - amount,
self:_sn(source.name))
end
return amount
end

View File

@@ -54,10 +54,7 @@ function ExportTask:cycle(context)
local _, item = next(items)
if item then
local count = math.min(item.count, itemDB:getMaxCount(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
context.storage:export(node, entry.slot, count, item)
break
end
end
@@ -70,8 +67,6 @@ function ExportTask:cycle(context)
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
_G._debug('EXPORTER warning: Failed to export %s %s[%d]',
node.displayName or node.name, item.name, item.count)
break
end
end

View File

@@ -55,10 +55,7 @@ function ImportTask:cycle(context)
return node.adapter.getItemMeta(slotNo)
end)
if item and matchesFilter(item) then
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
context.storage:import(node, slotNo, item.count, item)
end
end

View File

@@ -1,10 +1,10 @@
local peripheral = _G.peripheral
local device = _G.device
local ni = peripheral.find('neuralInterface')
if not ni then
error('Missing neural interface')
elseif not ni.disableAI then
local kinetic = device['plethora:kinetic'] or
error('Missing kinetic augment')
else
ni.disableAI()
if not kinetic.disableAI then
error('Nope')
end
kinetic.disableAI()

View File

@@ -1,10 +1,10 @@
local peripheral = _G.peripheral
local device = _G.device
local ni = peripheral.find('neuralInterface')
if not ni then
error('Missing neural interface')
elseif not ni.getEquipment then
error('Missing introspection module')
local intro = device['plethora:introspection'] or
error('Missing Introspection module')
if intro.getBaubles then
intro.getBaubles().drop(5)
else
ni.getEquipment().drop(6)
intro.getEquipment().drop(6)
end

View File

@@ -20,13 +20,32 @@ local function findTargets()
return l[1]
end
local last
local count = 0
while true do
local target = findTargets()
if target then
print('looking at ' .. target.name)
ni.lookAt(target)
os.sleep(0)
if target and (not last or Point.distance(last, target) > .2) then
-- last = target
if last then print(Point.distance(last, target)) end
last = target
--print(target.x, target.y, target.z, count)
ni.lookAt(target)
count = 0
os.sleep(0)
-- elseif count < 10 then
-- count = count + 1
-- os.sleep(.1)
-- end
else
os.sleep(3)
count = count + 1
if count > 50 or not target then
ni.lookAt({ x = math.random(-10, 10),
y = math.random(-10, 10),
z = math.random(-10, 10) })
os.sleep(3)
else
os.sleep(.1)
end
end
end