milo wip
This commit is contained in:
@@ -10,17 +10,9 @@ local craftTask = {
|
||||
priority = 70,
|
||||
}
|
||||
|
||||
-- Craft
|
||||
function craftTask:craftItem(recipe, originalItem, count)
|
||||
local toCraft = Craft.getCraftableAmount(recipe, count, Milo:listItems(), { })
|
||||
local crafted = 0
|
||||
|
||||
if toCraft > 0 then
|
||||
crafted = Craft.craftRecipe(recipe, toCraft, context.inventoryAdapter, originalItem)
|
||||
Milo:clearGrid()
|
||||
end
|
||||
|
||||
return crafted
|
||||
function craftTask:craftItem(recipe, item, count)
|
||||
Craft.craftRecipe(recipe, count, context.inventoryAdapter, item)
|
||||
Milo:clearGrid()
|
||||
end
|
||||
|
||||
-- Craft as much as possible regardless if all ingredients are available
|
||||
@@ -91,24 +83,21 @@ function craftTask:forceCraftItem(inRecipe, originalItem, inCount)
|
||||
end
|
||||
|
||||
function craftTask:craft(recipe, item)
|
||||
item.status = nil
|
||||
item.statusCode = nil
|
||||
|
||||
if Milo:isCraftingPaused() then
|
||||
return
|
||||
end
|
||||
|
||||
if item.forceCrafting then
|
||||
item.crafted = item.crafted + self:forceCraftItem(recipe, item, item.count - item.crafted)
|
||||
self:forceCraftItem(recipe, item, item.count - item.crafted)
|
||||
else
|
||||
item.crafted = item.crafted + self:craftItem(recipe, item, item.count - item.crafted)
|
||||
self:craftItem(recipe, item, item.count - item.crafted)
|
||||
end
|
||||
end
|
||||
|
||||
function craftTask:cycle()
|
||||
for _,key in pairs(Util.keys(context.craftingQueue)) do
|
||||
local item = context.craftingQueue[key]
|
||||
if item.count > 0 then
|
||||
if item.count - item.crafted > 0 then
|
||||
local recipe = Craft.recipes[key]
|
||||
if recipe then
|
||||
self:craft(recipe, item)
|
||||
|
||||
@@ -20,7 +20,7 @@ local jobList = UI.Page {
|
||||
sortColumn = 'index',
|
||||
backgroundFocusColor = colors.black,
|
||||
columns = {
|
||||
{ heading = 'Qty', key = 'remaining', width = 6 },
|
||||
{ heading = 'Qty', key = 'remaining', width = 4 },
|
||||
{ heading = 'Crafting', key = 'displayName', },
|
||||
{ heading = 'Status', key = 'status', },
|
||||
{ heading = 'Req', key = 'count', width = 3 },
|
||||
@@ -41,13 +41,15 @@ function jobList:updateList(craftList)
|
||||
for _,v in pairs(craftList) do
|
||||
table.insert(t, v)
|
||||
v.index = #t
|
||||
v.showRemining = true
|
||||
v.showRemaining = true
|
||||
for k2,v2 in pairs(v.ingredients) do
|
||||
table.insert(t, v2)
|
||||
if not v2.displayName then
|
||||
v2.displayName = itemDB:getName(k2)
|
||||
if v2 ~= v then
|
||||
table.insert(t, v2)
|
||||
if not v2.displayName then
|
||||
v2.displayName = itemDB:getName(k2)
|
||||
end
|
||||
v2.index = #t
|
||||
end
|
||||
v2.index = #t
|
||||
end
|
||||
end
|
||||
self.grid:setValues(t)
|
||||
@@ -59,8 +61,10 @@ end
|
||||
|
||||
function jobList.grid:getDisplayValues(row)
|
||||
row = Util.shallowCopy(row)
|
||||
if row.showRemining then
|
||||
if row.showRemaining then
|
||||
row.remaining = row.count - row.crafted
|
||||
else
|
||||
row.displayName = ' ' .. row.displayName
|
||||
end
|
||||
return row
|
||||
end
|
||||
|
||||
@@ -116,6 +116,8 @@ function pages.confirmation:validate()
|
||||
end
|
||||
end
|
||||
|
||||
-- TODO: maxCount needs to be entered by user ? ie. brewing station can only do 1 at a time
|
||||
|
||||
local recipe = {
|
||||
count = result.count,
|
||||
ingredients = { },
|
||||
@@ -131,12 +133,13 @@ function pages.confirmation:validate()
|
||||
-- save the recipe
|
||||
context.userRecipes[key] = recipe
|
||||
Util.writeTable(Milo.RECIPES_FILE, context.userRecipes)
|
||||
Craft.loadRecipes()
|
||||
|
||||
-- save the machine association
|
||||
Craft.machineLookup[key] = machine.name
|
||||
Util.writeTable(MACHINE_LOOKUP, Craft.machineLookup)
|
||||
|
||||
Craft.loadRecipes()
|
||||
|
||||
local listingPage = UI:getPage('listing')
|
||||
local displayName = itemDB:getName(result)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user