milo wip
This commit is contained in:
@@ -129,6 +129,20 @@ function Milo:clearGrid()
|
||||
return clear() or clear()
|
||||
end
|
||||
|
||||
function Milo:getTurtleInventory()
|
||||
local list = { }
|
||||
for i = 1,16 do
|
||||
-- TODO: update item db
|
||||
local item = self.context.introspectionModule.getInventory().getItemMeta(i)
|
||||
if item then
|
||||
itemDB:add(item)
|
||||
list[i] = item
|
||||
end
|
||||
end
|
||||
itemDB:flush()
|
||||
return list
|
||||
end
|
||||
|
||||
function Milo:eject(item, qty)
|
||||
local s, m = pcall(function()
|
||||
self.context.storage:provide(item, qty)
|
||||
|
||||
@@ -23,17 +23,24 @@ listCount = 0,
|
||||
local modem = Peripheral.get('wired_modem') or error('Wired modem not attached')
|
||||
self.localName = modem.getNameLocal()
|
||||
|
||||
Event.on({ 'device_attach' }, function(_, dev)
|
||||
debug('attach: ' .. dev)
|
||||
Event.on({ 'device_attach', 'device_detach' }, function(e, dev)
|
||||
debug('%s: %s', e, tostring(dev))
|
||||
self:initStorage()
|
||||
end)
|
||||
|
||||
Event.on({ 'device_detach' }, function(_, dev)
|
||||
debug('detach: ' .. dev)
|
||||
self:initStorage(dev)
|
||||
Event.onInterval(15, function()
|
||||
self:showStorage()
|
||||
end)
|
||||
end
|
||||
|
||||
function NetworkedAdapter:showStorage()
|
||||
debug('Storage:')
|
||||
for k,v in pairs(self.remoteDefaults) do
|
||||
local online = v.adapter and v.adapter.online
|
||||
debug(' %s: %s', online and ' online' or 'offline', k)
|
||||
end
|
||||
debug('')
|
||||
end
|
||||
|
||||
function NetworkedAdapter:setOnline(online)
|
||||
if online ~= self.storageOnline then
|
||||
self.storageOnline = online
|
||||
@@ -59,7 +66,6 @@ function NetworkedAdapter:initStorage()
|
||||
end
|
||||
if v.mtype == 'storage' then
|
||||
online = online and not not (v.adapter and v.adapter.online)
|
||||
debug(' %s: %s', v.adapter and v.adapter.online and ' online' or 'offline', k)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user