This commit is contained in:
kepler155c
2018-10-27 23:16:16 -04:00
parent 57e7a574c4
commit dc6af1d0c3
4 changed files with 44 additions and 9 deletions

View File

@@ -10,11 +10,15 @@ local colors = _G.colors
local device = _G.device local device = _G.device
local socket local socket
local SHIELD_SLOT = 2
local options = { local options = {
user = { arg = 'u', type = 'string', user = { arg = 'u', type = 'string',
desc = 'User name associated with bound manipulator' }, desc = 'User name associated with bound manipulator' },
slot = { arg = 's', type = 'number', slot = { arg = 's', type = 'number',
desc = 'Optional inventory slot to use to transfer to milo' }, desc = 'Optional inventory slot to use to transfer to milo' },
shield = { arg = 'e', type = 'flag',
desc = 'Use shield slot to use to transfer to milo' },
server = { arg = 'm', type = 'number', server = { arg = 'm', type = 'number',
desc = 'ID of Milo server' }, desc = 'ID of Milo server' },
help = { arg = 'h', type = 'flag', value = false, help = { arg = 'h', type = 'flag', value = false,
@@ -33,7 +37,7 @@ if not options.user.value or not options.server.value then
error('Invalid arguments') error('Invalid arguments')
end end
if options.slot.value and if (options.slot.value or options.shield.value) and
not (device.neuralInterface and device.neuralInterface.getInventory) then not (device.neuralInterface and device.neuralInterface.getInventory) then
error('Introspection module is required for transferring items') error('Introspection module is required for transferring items')
end end
@@ -246,7 +250,7 @@ end
if options.slot.value then if options.slot.value then
debug('Transfer items initialized') debug('Transfer items initialized')
Event.onInterval(1, function() Event.onInterval(2, function()
local neural = device.neuralInterface local neural = device.neuralInterface
if neural and neural.getInventory then if neural and neural.getInventory then
local item = neural.getInventory().getItem(options.slot.value) local item = neural.getInventory().getItem(options.slot.value)
@@ -263,6 +267,25 @@ if options.slot.value then
end) end)
end end
if options.slot.value or options.eslot.value then
debug('Transfer items initialized')
Event.onInterval(2, function()
local neural = device.neuralInterface
if neural and neural.getEquipment then
local item = neural.getEquipment().getItem(SHIELD_SLOT)
if item then
debug('depositing')
page:sendRequest({ request = 'deposit', slot = 'shield' })
-- local item =
-- TODO: update count for this one item
-- page.grid:draw() page:sync()
end
else
debug('missing Introspection module')
end
end)
end
UI:setPage(page) UI:setPage(page)
UI:pullEvents() UI:pullEvents()

View File

@@ -36,7 +36,9 @@ function NetworkedAdapter:showStorage()
debug('Storage:') debug('Storage:')
for k,v in pairs(self.remoteDefaults) do for k,v in pairs(self.remoteDefaults) do
local online = v.adapter and v.adapter.online local online = v.adapter and v.adapter.online
debug(' %s: %s', online and ' online' or 'offline', k) if not online then
debug(' %s: %s', online and ' online' or 'offline', k)
end
end end
debug('') debug('')
end end

View File

@@ -359,8 +359,7 @@ function machineWizard.wizard:eventHandler(event)
self.pages.general.index = 1 self.pages.general.index = 1
self.pages.confirmation.index = 2 self.pages.confirmation.index = 2
for k, page in pairs(self.pages) do for _, page in pairs(self.pages) do
debug(k)
if not page.index and page:isValidFor(self.parent.machine) then if not page.index and page:isValidFor(self.parent.machine) then
page.index = index page.index = index
index = index + 1 index = index + 1

View File

@@ -5,6 +5,8 @@ local Socket = require('socket')
local device = _G.device local device = _G.device
local turtle = _G.turtle local turtle = _G.turtle
local SHIELD_SLOT = 2
local context = Milo:getContext() local context = Milo:getContext()
local function getManipulatorForUser(user) local function getManipulatorForUser(user)
@@ -40,10 +42,19 @@ debug('remote: ' .. data.request)
socket:write(items) socket:write(items)
elseif data.request == 'deposit' then elseif data.request == 'deposit' then
local count = manipulator.getInventory().pushItems( local count
context.localName,
data.slot, if data.slot == 'shield' then
64) count = manipulator.getEquipment().pushItems(
context.localName,
SHIELD_SLOT,
64)
else
count = manipulator.getInventory().pushItems(
context.localName,
data.slot,
64)
end
socket:write({ count = count }) socket:write({ count = count })
Milo:clearGrid() Milo:clearGrid()