milo wip
This commit is contained in:
@@ -99,11 +99,15 @@ function craftTask:cycle()
|
||||
for _,key in pairs(Util.keys(context.craftingQueue)) do
|
||||
local item = context.craftingQueue[key]
|
||||
if item.count - item.crafted > 0 then
|
||||
local recipe = Craft.recipes[key]
|
||||
local recipe = Craft.findRecipe(key)
|
||||
if recipe then
|
||||
self:craft(recipe, item)
|
||||
if item.eject and item.crafted >= item.count then
|
||||
Milo:eject(item, item.count)
|
||||
if type(item.eject) == 'boolean' then
|
||||
Milo:eject(item, item.count)
|
||||
else
|
||||
item.eject(item.count, 0) -- unknown amount in system
|
||||
end
|
||||
end
|
||||
elseif not context.controllerAdapter then
|
||||
item.status = '(no recipe)'
|
||||
|
||||
@@ -91,6 +91,8 @@ local listingPage = UI.Page {
|
||||
q = 'quit',
|
||||
[ 'control-e' ] = 'eject',
|
||||
[ 'control-s' ] = 'eject_stack',
|
||||
[ 'control-a' ] = 'eject_all',
|
||||
|
||||
[ 'control-1' ] = 'eject_1',
|
||||
[ 'control-2' ] = 'eject_1',
|
||||
[ 'control-3' ] = 'eject_1',
|
||||
@@ -144,9 +146,7 @@ function listingPage:eventHandler(event)
|
||||
local item = self.grid:getSelected()
|
||||
if item then
|
||||
queue(function()
|
||||
Milo:eject(item, 1)
|
||||
local updated = Milo:getItem(Milo:listItems(), item)
|
||||
item.count = updated and updated.count or 0
|
||||
item.count = Milo:xxx(item, 1)
|
||||
self.grid:draw()
|
||||
end)
|
||||
end
|
||||
@@ -154,7 +154,19 @@ function listingPage:eventHandler(event)
|
||||
elseif event.type == 'eject_stack' then
|
||||
local item = self.grid:getSelected()
|
||||
if item then
|
||||
queue(function() Milo:eject(item, itemDB:getMaxCount(item)) end)
|
||||
queue(function()
|
||||
item.count = Milo:xxx(item, itemDB:getMaxCount(item))
|
||||
self.grid:draw()
|
||||
end)
|
||||
end
|
||||
|
||||
elseif event.type == 'eject_all' then
|
||||
local item = self.grid:getSelected()
|
||||
if item then
|
||||
local updated = Milo:getItem(Milo:listItems(), item)
|
||||
if updated then
|
||||
queue(function() Milo:eject(item, updated.count) end)
|
||||
end
|
||||
end
|
||||
|
||||
elseif event.type == 'machines' then
|
||||
@@ -235,9 +247,23 @@ end
|
||||
function listingPage:enable()
|
||||
self:refresh()
|
||||
self:setFocus(self.statusBar.filter)
|
||||
self.timer = Event.onInterval(5, function()
|
||||
for _,v in pairs(self.allItems) do
|
||||
if not v.key then debug(v) error('') end
|
||||
local c = context.storage.cache[v.key]
|
||||
v.count = c and c.count or 0
|
||||
end
|
||||
self.grid:draw()
|
||||
self:sync()
|
||||
end)
|
||||
UI.Page.enable(self)
|
||||
end
|
||||
|
||||
function listingPage:disable()
|
||||
Event.off(self.timer)
|
||||
UI.Page.disable(self)
|
||||
end
|
||||
|
||||
function listingPage:refresh()
|
||||
self.allItems = Milo:refreshItems()
|
||||
Milo:mergeResources(self.allItems)
|
||||
|
||||
@@ -59,17 +59,20 @@ debug('remote: ' .. data.request)
|
||||
Milo:clearGrid()
|
||||
|
||||
elseif data.request == 'transfer' then
|
||||
local count = context.storage:export(
|
||||
context.localName,
|
||||
nil,
|
||||
data.count,
|
||||
data.item)
|
||||
|
||||
turtle.eachFilledSlot(function(slot)
|
||||
manipulator.getInventory().pullItems(
|
||||
local count = Milo:provideItem(data.item, data.count, function(amount, currentCount)
|
||||
amount = context.storage:export(
|
||||
context.localName,
|
||||
slot.index,
|
||||
slot.count)
|
||||
nil,
|
||||
amount,
|
||||
data.item)
|
||||
|
||||
turtle.eachFilledSlot(function(slot)
|
||||
manipulator.getInventory().pullItems(
|
||||
context.localName,
|
||||
slot.index,
|
||||
slot.count)
|
||||
end)
|
||||
return currentCount - amount
|
||||
end)
|
||||
|
||||
socket:write({ count = count })
|
||||
|
||||
Reference in New Issue
Block a user