diff --git a/milo/apis/storage.lua b/milo/apis/storage.lua index 14341b5..04617f6 100644 --- a/milo/apis/storage.lua +++ b/milo/apis/storage.lua @@ -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 diff --git a/milo/plugins/exportTask.lua b/milo/plugins/exportTask.lua index 561c55d..5114f30 100644 --- a/milo/plugins/exportTask.lua +++ b/milo/plugins/exportTask.lua @@ -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 diff --git a/milo/plugins/importTask.lua b/milo/plugins/importTask.lua index 29050af..f27a830 100644 --- a/milo/plugins/importTask.lua +++ b/milo/plugins/importTask.lua @@ -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 diff --git a/neural/disableAI.lua b/neural/disableAI.lua index 8e5aa26..a9c283b 100644 --- a/neural/disableAI.lua +++ b/neural/disableAI.lua @@ -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() diff --git a/neural/dropNeural.lua b/neural/dropNeural.lua index 6b4bc5f..f4246e8 100644 --- a/neural/dropNeural.lua +++ b/neural/dropNeural.lua @@ -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 diff --git a/neural/neuralLook.lua b/neural/neuralLook.lua index d590b65..051de04 100644 --- a/neural/neuralLook.lua +++ b/neural/neuralLook.lua @@ -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