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 socket
local SHIELD_SLOT = 2
local options = {
user = { arg = 'u', type = 'string',
desc = 'User name associated with bound manipulator' },
slot = { arg = 's', type = 'number',
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',
desc = 'ID of Milo server' },
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')
end
if options.slot.value and
if (options.slot.value or options.shield.value) and
not (device.neuralInterface and device.neuralInterface.getInventory) then
error('Introspection module is required for transferring items')
end
@@ -246,7 +250,7 @@ end
if options.slot.value then
debug('Transfer items initialized')
Event.onInterval(1, function()
Event.onInterval(2, function()
local neural = device.neuralInterface
if neural and neural.getInventory then
local item = neural.getInventory().getItem(options.slot.value)
@@ -263,6 +267,25 @@ if options.slot.value then
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:pullEvents()

View File

@@ -36,7 +36,9 @@ 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)
if not online then
debug(' %s: %s', online and ' online' or 'offline', k)
end
end
debug('')
end

View File

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

View File

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