milo wip
This commit is contained in:
@@ -25,7 +25,7 @@ function ExportTask:cycle(context)
|
||||
item = Milo:getItemWithQty(item)
|
||||
if item and count > 0 then
|
||||
context.inventoryAdapter:provide(
|
||||
itemDB:splitKey(entry.name),
|
||||
item,
|
||||
math.min(count, item.count),
|
||||
entry.slot,
|
||||
target)
|
||||
|
||||
@@ -92,9 +92,9 @@ function itemSlideout.grid:enable()
|
||||
UI.Grid.enable(self)
|
||||
end
|
||||
|
||||
function itemSlideout:show(machine, entry)
|
||||
self.machine = machine
|
||||
function itemSlideout:show(machine, entry, callback)
|
||||
self.entry = entry
|
||||
self.callback = callback
|
||||
|
||||
self.form.choices = { }
|
||||
local m = device[machine.name]
|
||||
@@ -131,8 +131,9 @@ function itemSlideout:eventHandler(event)
|
||||
else
|
||||
self.form:save()
|
||||
self.form.values.name = itemDB:makeKey(selected)
|
||||
table.insert(self.machine.exports, self.form.values)
|
||||
self:hide()
|
||||
debug('calling cllbck')
|
||||
self.callback()
|
||||
end
|
||||
|
||||
elseif event.type == 'cancel' then
|
||||
@@ -194,10 +195,18 @@ end
|
||||
|
||||
function exportView:eventHandler(event)
|
||||
if event.type == 'grid_select' then
|
||||
itemSlideout:show(self.machine, self.grid:getSelected())
|
||||
itemSlideout:show(self.machine, self.grid:getSelected(), function()
|
||||
self.grid:update()
|
||||
self.grid:draw()
|
||||
end)
|
||||
|
||||
elseif event.type == 'add_export' then
|
||||
itemSlideout:show(self.machine, { })
|
||||
local export = { }
|
||||
itemSlideout:show(self.machine, export, function()
|
||||
table.insert(self.machine.exports, export)
|
||||
self.grid:update()
|
||||
self.grid:draw()
|
||||
end)
|
||||
|
||||
elseif event.type == 'remove_export' then
|
||||
local row = self.grid:getSelected()
|
||||
|
||||
@@ -32,10 +32,12 @@ function jobList:showError(msg)
|
||||
end
|
||||
|
||||
function jobList:updateList(craftList)
|
||||
self.grid:setValues(craftList)
|
||||
self.grid:update()
|
||||
self:draw()
|
||||
self:sync()
|
||||
if not Milo:isCraftingPaused() then
|
||||
self.grid:setValues(craftList)
|
||||
self.grid:update()
|
||||
self:draw()
|
||||
self:sync()
|
||||
end
|
||||
end
|
||||
|
||||
function jobList.grid:getRowTextColor(row, selected)
|
||||
|
||||
@@ -78,6 +78,7 @@ local listingPage = UI.Page {
|
||||
notification = UI.Notification(),
|
||||
accelerators = {
|
||||
r = 'refresh',
|
||||
[ 'control-r' ] = 'refresh',
|
||||
q = 'quit',
|
||||
[ 'control-e' ] = 'eject',
|
||||
[ 'control-s' ] = 'eject_stack',
|
||||
|
||||
52
milo/plugins/remote.lua
Normal file
52
milo/plugins/remote.lua
Normal file
@@ -0,0 +1,52 @@
|
||||
local Event = require('event')
|
||||
local Milo = require('milo')
|
||||
local Socket = require('socket')
|
||||
|
||||
local device = _G.device
|
||||
local manipulator = device.manipulator_1
|
||||
local turtle = _G.turtle
|
||||
|
||||
local context = Milo:getContext()
|
||||
|
||||
local function client(socket)
|
||||
repeat
|
||||
local data = socket:read()
|
||||
if not data then
|
||||
break
|
||||
end
|
||||
if data.request == 'list' then
|
||||
local items = Milo:listItems()
|
||||
Milo:mergeResources(items)
|
||||
socket:write(items)
|
||||
|
||||
elseif data.request == 'transfer' then
|
||||
context.inventoryAdapter:provide(
|
||||
data.item,
|
||||
data.count,
|
||||
nil,
|
||||
context.localName)
|
||||
|
||||
turtle.eachFilledSlot(function(slot)
|
||||
manipulator.getInventory().pullItems(
|
||||
context.localName,
|
||||
slot.index,
|
||||
slot.count)
|
||||
end)
|
||||
end
|
||||
until not socket.connected
|
||||
end
|
||||
|
||||
if device.wireless_modem then
|
||||
Event.addRoutine(function()
|
||||
debug('Milo: listening on port 4242')
|
||||
while true do
|
||||
local socket = Socket.server(4242)
|
||||
|
||||
debug('connection from ' .. socket.dhost)
|
||||
|
||||
Event.addRoutine(function()
|
||||
client(socket)
|
||||
end)
|
||||
end
|
||||
end)
|
||||
end
|
||||
Reference in New Issue
Block a user