milo wip
This commit is contained in:
@@ -70,6 +70,7 @@ function craftTask:forceCraftItem(inRecipe, originalItem, inCount)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if craftable > 0 then
|
||||
craftable = Craft.craftRecipe(recipe, craftable * recipe.count,
|
||||
context.inventoryAdapter, originalItem) / recipe.count
|
||||
|
||||
@@ -132,7 +132,6 @@ function itemSlideout:eventHandler(event)
|
||||
self.form:save()
|
||||
self.form.values.name = itemDB:makeKey(selected)
|
||||
self:hide()
|
||||
debug('calling cllbck')
|
||||
self.callback()
|
||||
end
|
||||
|
||||
|
||||
@@ -36,24 +36,12 @@ local itemPage = UI.Page {
|
||||
help = 'Craft until out of ingredients'
|
||||
},
|
||||
]]
|
||||
[4] = UI.Chooser {
|
||||
width = 7,
|
||||
[4] = UI.Checkbox {
|
||||
formLabel = 'Ignore Dmg', formKey = 'ignoreDamage',
|
||||
nochoice = 'No',
|
||||
choices = {
|
||||
{ name = 'Yes', value = true },
|
||||
{ name = 'No', value = false },
|
||||
},
|
||||
help = 'Ignore damage of item'
|
||||
},
|
||||
[5] = UI.Chooser {
|
||||
width = 7,
|
||||
[5] = UI.Checkbox {
|
||||
formLabel = 'Ignore NBT', formKey = 'ignoreNbtHash',
|
||||
nochoice = 'No',
|
||||
choices = {
|
||||
{ name = 'Yes', value = true },
|
||||
{ name = 'No', value = false },
|
||||
},
|
||||
help = 'Ignore NBT of item'
|
||||
},
|
||||
--[[
|
||||
|
||||
@@ -23,8 +23,7 @@ local jobList = UI.Page {
|
||||
{ heading = 'Qty', key = 'remaining', width = 4 },
|
||||
{ heading = 'Crafting', key = 'displayName', },
|
||||
{ heading = 'Status', key = 'status', },
|
||||
{ heading = 'Req', key = 'count', width = 3 },
|
||||
{ heading = 'Cra', key = 'crafted', width = 3 },
|
||||
{ heading = 'Progress', key = 'progress', width = 8 },
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -66,6 +65,7 @@ function jobList.grid:getDisplayValues(row)
|
||||
else
|
||||
row.displayName = ' ' .. row.displayName
|
||||
end
|
||||
row.progress = string.format('%d/%d', row.crafted, row.count)
|
||||
return row
|
||||
end
|
||||
|
||||
|
||||
@@ -40,9 +40,10 @@ end
|
||||
local listingPage = UI.Page {
|
||||
menuBar = UI.MenuBar {
|
||||
buttons = {
|
||||
{ text = 'Learn', event = 'learn' },
|
||||
{ text = 'Forget', event = 'forget' },
|
||||
{ text = 'Craft', event = 'craft' },
|
||||
{ text = 'Learn', event = 'learn' },
|
||||
{ text = 'Forget', event = 'forget' },
|
||||
{ text = 'Craft', event = 'craft' },
|
||||
{ text = '...', event = 'machines' },
|
||||
{ text = 'Refresh', event = 'refresh', x = -9 },
|
||||
},
|
||||
},
|
||||
@@ -134,7 +135,12 @@ function listingPage:eventHandler(event)
|
||||
elseif event.type == 'eject' then
|
||||
local item = self.grid:getSelected()
|
||||
if item then
|
||||
queue(function() Milo:eject(item, 1) end)
|
||||
queue(function()
|
||||
Milo:eject(item, 1)
|
||||
local updated = Milo:getItem(Milo:listItems(), item)
|
||||
item.count = updated and updated.count or 0
|
||||
self.grid:draw()
|
||||
end)
|
||||
end
|
||||
|
||||
elseif event.type == 'eject_stack' then
|
||||
@@ -225,7 +231,7 @@ function listingPage:enable()
|
||||
end
|
||||
|
||||
function listingPage:refresh()
|
||||
self.allItems = context.inventoryAdapter:refresh()
|
||||
self.allItems = Milo:refreshItems()
|
||||
Milo:mergeResources(self.allItems)
|
||||
self:applyFilter()
|
||||
end
|
||||
|
||||
@@ -34,12 +34,20 @@ local function client(socket)
|
||||
break
|
||||
end
|
||||
if data.request == 'list' then
|
||||
local items = Milo:listItems()
|
||||
local items = Milo:refreshItems()
|
||||
Milo:mergeResources(items)
|
||||
socket:write(items)
|
||||
|
||||
elseif data.request == 'deposit' then
|
||||
local count = manipulator.getInventory().pushItems(
|
||||
context.localName,
|
||||
data.slot,
|
||||
64)
|
||||
socket:write({ count = count })
|
||||
Milo:clearGrid()
|
||||
|
||||
elseif data.request == 'transfer' then
|
||||
context.inventoryAdapter:provide(
|
||||
local count = context.inventoryAdapter:provide(
|
||||
data.item,
|
||||
data.count,
|
||||
nil,
|
||||
@@ -52,9 +60,7 @@ local function client(socket)
|
||||
slot.count)
|
||||
end)
|
||||
|
||||
local items = Milo:listItems()
|
||||
Milo:mergeResources(items)
|
||||
socket:write(items)
|
||||
socket:write({ count = count })
|
||||
end
|
||||
until not socket.connected
|
||||
|
||||
|
||||
@@ -30,7 +30,13 @@ function ReplenishTask:cycle(context)
|
||||
count = res.low - item.count,
|
||||
name = item.name,
|
||||
displayName = item.displayName,
|
||||
replenish = true,
|
||||
})
|
||||
else
|
||||
local request = context.craftingQueue[Milo:uniqueKey(item)]
|
||||
if request and request.replenish then
|
||||
request.count = request.crafted
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
local itemDB = require('itemDB')
|
||||
local UI = require('ui')
|
||||
|
||||
local colors = _G.colors
|
||||
local device = _G.device
|
||||
|
||||
local storageView = UI.Window {
|
||||
mtype = 'storage',
|
||||
@@ -16,14 +18,24 @@ local storageView = UI.Window {
|
||||
limit = 4,
|
||||
validate = 'numeric', pruneEmpty = true,
|
||||
},
|
||||
[2] = UI.TextEntry {
|
||||
formLabel = 'Lock to', formKey = 'lockWith',
|
||||
[2] = UI.Checkbox {
|
||||
formLabel = 'Locked', formKey = 'lockWith',
|
||||
help = 'Locks chest to a single item type',
|
||||
width = 18, limit = 64, pruneEmpty = true,
|
||||
pruneEmpty = true,
|
||||
},
|
||||
[3] = UI.Button {
|
||||
x = -9, ey = -4,
|
||||
text = 'Detect', help = 'Determine what is currently present',
|
||||
[3] = UI.Text {
|
||||
x = 16, ex = -2, y = 3,
|
||||
value = 'minecraft:xxxxx:0'
|
||||
},
|
||||
[4] = UI.Checkbox {
|
||||
formLabel = 'Void', formKey = 'voidExcess',
|
||||
help = 'Void excess if locked - TODO',
|
||||
pruneEmpty = true,
|
||||
},
|
||||
[5] = UI.Checkbox {
|
||||
formLabel = 'Partition', formKey = 'voidExcess',
|
||||
help = 'TODO',
|
||||
pruneEmpty = true,
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -38,7 +50,33 @@ function storageView:validate()
|
||||
end
|
||||
|
||||
function storageView:setMachine(machine)
|
||||
self.machine = machine
|
||||
self.form:setValues(machine)
|
||||
self.form[3].value = machine.lock and itemDB:getName(machine.lock) or ''
|
||||
end
|
||||
|
||||
function storageView:eventHandler(event)
|
||||
if event.type == 'checkbox_change' and event.element.formKey == 'lockWith' then
|
||||
if event.checked then
|
||||
if device[self.machine.name] and device[self.machine.name].list then
|
||||
local _, slot = next(device[self.machine.name].list())
|
||||
if slot then
|
||||
self.machine.lock = itemDB:makeKey(slot)
|
||||
self.form[3].value = itemDB:getName(slot)
|
||||
else
|
||||
self:emit({
|
||||
type = 'general_error',
|
||||
field = event.element,
|
||||
message = 'The chest must contain the item to lock' })
|
||||
self.form[3].value = false
|
||||
end
|
||||
end
|
||||
else
|
||||
self.machine.lock = nil
|
||||
self.form[3].value = ''
|
||||
end
|
||||
self.form[3]:draw()
|
||||
end
|
||||
end
|
||||
|
||||
UI:getPage('machineWizard').wizard:add({ storage = storageView })
|
||||
|
||||
Reference in New Issue
Block a user