milo wip
This commit is contained in:
@@ -113,6 +113,8 @@ local context = {
|
|||||||
craftingQueue = { },
|
craftingQueue = { },
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_G._p = context--debug
|
||||||
|
|
||||||
local function initStorage(detachedDevice)
|
local function initStorage(detachedDevice)
|
||||||
debug('Initializing storage')
|
debug('Initializing storage')
|
||||||
local storage = { }
|
local storage = { }
|
||||||
@@ -142,7 +144,9 @@ debug(storage)
|
|||||||
debug('resuming')
|
debug('resuming')
|
||||||
Milo:resumeCrafting()
|
Milo:resumeCrafting()
|
||||||
end
|
end
|
||||||
|
--TODO: cannot do this, must be able to add and mark inactive
|
||||||
|
-- due to activity table
|
||||||
|
-- add an networkAdapter:scan()
|
||||||
context.inventoryAdapter = InventoryAdapter.wrap({ remoteDefaults = storage })
|
context.inventoryAdapter = InventoryAdapter.wrap({ remoteDefaults = storage })
|
||||||
|
|
||||||
if not context.inventoryAdapter then
|
if not context.inventoryAdapter then
|
||||||
@@ -151,7 +155,7 @@ debug(storage)
|
|||||||
end
|
end
|
||||||
|
|
||||||
Event.on({ 'device_attach' }, function(_, dev)
|
Event.on({ 'device_attach' }, function(_, dev)
|
||||||
debug('attach: ' .. dev)
|
--debug('attach: ' .. dev)
|
||||||
if config.remoteDefaults[dev] and
|
if config.remoteDefaults[dev] and
|
||||||
config.remoteDefaults[dev].mtype == 'storage' then
|
config.remoteDefaults[dev].mtype == 'storage' then
|
||||||
initStorage()
|
initStorage()
|
||||||
@@ -159,7 +163,7 @@ Event.on({ 'device_attach' }, function(_, dev)
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
Event.on({ 'device_detach' }, function(_, dev)
|
Event.on({ 'device_detach' }, function(_, dev)
|
||||||
debug('detach: ' .. dev)
|
--debug('detach: ' .. dev)
|
||||||
if config.remoteDefaults[dev] and
|
if config.remoteDefaults[dev] and
|
||||||
config.remoteDefaults[dev].mtype == 'storage' then
|
config.remoteDefaults[dev].mtype == 'storage' then
|
||||||
initStorage(dev)
|
initStorage(dev)
|
||||||
|
|||||||
@@ -22,13 +22,11 @@ function Milo:requestCrafting(item)
|
|||||||
local key = Milo:uniqueKey(item)
|
local key = Milo:uniqueKey(item)
|
||||||
|
|
||||||
if not self.context.craftingQueue[key] then
|
if not self.context.craftingQueue[key] then
|
||||||
item.ingredients = { }
|
item.ingredients = {
|
||||||
--[[
|
[ key ] = item
|
||||||
count = requested amount,
|
}
|
||||||
crafted = amount that has been crafted
|
-- item.ingredients[key] = item
|
||||||
]]
|
|
||||||
item.crafted = 0
|
item.crafted = 0
|
||||||
|
|
||||||
self.context.craftingQueue[key] = item
|
self.context.craftingQueue[key] = item
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -115,9 +115,9 @@ function NetworkedAdapter:provide(item, qty, slot, direction)
|
|||||||
for _, remote in ipairs(self.remotes) do
|
for _, remote in ipairs(self.remotes) do
|
||||||
local amount = remote:provide(item, qty, slot, direction)
|
local amount = remote:provide(item, qty, slot, direction)
|
||||||
if amount > 0 then
|
if amount > 0 then
|
||||||
debug('EXT: %s(%d): %s -> %s%s',
|
--debug('EXT: %s(%d): %s -> %s%s',
|
||||||
item.name, amount, remote.side, direction or self.localName,
|
-- item.name, amount, remote.side, direction or self.localName,
|
||||||
slot and string.format('[%d]', slot) or '')
|
-- slot and string.format('[%d]', slot) or '')
|
||||||
self.dirty = true
|
self.dirty = true
|
||||||
remote.dirty = true
|
remote.dirty = true
|
||||||
end
|
end
|
||||||
@@ -165,12 +165,11 @@ function NetworkedAdapter:insert(slot, qty, toSlot, item, source)
|
|||||||
local function insert(remote)
|
local function insert(remote)
|
||||||
local amount = remote:insert(slot, qty, toSlot, source or self.direction)
|
local amount = remote:insert(slot, qty, toSlot, source or self.direction)
|
||||||
if amount > 0 then
|
if amount > 0 then
|
||||||
debug('INS: %s(%d): %s[%d] -> %s',
|
--debug('INS: %s(%d): %s[%d] -> %s',
|
||||||
item.name, amount,
|
-- item.name, amount,
|
||||||
source or self.localName, slot, remote.side)
|
-- source or self.localName, slot, remote.side)
|
||||||
self.dirty = true
|
self.dirty = true
|
||||||
remote.dirty = true
|
remote.dirty = true
|
||||||
debug('insert: ' .. (source or self.localName))
|
|
||||||
local entry = self.activity[key] or 0
|
local entry = self.activity[key] or 0
|
||||||
self.activity[key] = entry + amount
|
self.activity[key] = entry + amount
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -41,6 +41,13 @@ local function splitKey(key)
|
|||||||
return item
|
return item
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function makeRecipeKey(item)
|
||||||
|
if type(item) == 'string' then
|
||||||
|
item = splitKey(item)
|
||||||
|
end
|
||||||
|
return table.concat({ item.name, item.damage or 0, item.nbtHash }, ':')
|
||||||
|
end
|
||||||
|
|
||||||
function Craft.getItemCount(items, item)
|
function Craft.getItemCount(items, item)
|
||||||
if type(item) == 'string' then
|
if type(item) == 'string' then
|
||||||
item = splitKey(item)
|
item = splitKey(item)
|
||||||
@@ -60,25 +67,25 @@ function Craft.getItemCount(items, item)
|
|||||||
return count
|
return count
|
||||||
end
|
end
|
||||||
|
|
||||||
local function machineCraft(recipe, qty, inventoryAdapter, machineName, oitem)
|
function Craft.sumIngredients(recipe)
|
||||||
local key = recipe.result
|
-- produces { ['minecraft:planks:0'] = 8 }
|
||||||
local request = oitem.ingredients[key]
|
local t = { }
|
||||||
|
for _,item in pairs(recipe.ingredients) do
|
||||||
if not request then
|
t[item] = (t[item] or 0) + 1
|
||||||
request = {
|
|
||||||
count = qty,
|
|
||||||
crafted = 0,
|
|
||||||
}
|
|
||||||
oitem.ingredients[recipe.result] = request
|
|
||||||
end
|
end
|
||||||
|
-- need a check for crafting tool
|
||||||
|
return t
|
||||||
|
end
|
||||||
|
|
||||||
|
local function machineCraft(recipe, inventoryAdapter, machineName, request, count)
|
||||||
if request.pending then
|
if request.pending then
|
||||||
request.crafted = request.crafted + (inventoryAdapter.activity[key] or 0)
|
local imported = (inventoryAdapter.activity[recipe.result] or 0)
|
||||||
if request.crafted >= request.count then
|
request.pending = request.pending - imported
|
||||||
request.pending = nil -- TODO: check...
|
request.crafted = request.crafted + imported
|
||||||
request.statusCode = Craft.STATUS_SUCCESS
|
if request.pending <= 0 then
|
||||||
|
request.pending = nil
|
||||||
|
request.statusCode = nil
|
||||||
request.status = nil
|
request.status = nil
|
||||||
return true
|
|
||||||
end
|
end
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@@ -99,7 +106,7 @@ local function machineCraft(recipe, qty, inventoryAdapter, machineName, oitem)
|
|||||||
end
|
end
|
||||||
|
|
||||||
for k,v in pairs(recipe.ingredients) do
|
for k,v in pairs(recipe.ingredients) do
|
||||||
if inventoryAdapter:provide(splitKey(v), qty, k, machineName) ~= qty then
|
if inventoryAdapter:provide(splitKey(v), count, k, machineName) ~= count then
|
||||||
-- TODO: suck em back out
|
-- TODO: suck em back out
|
||||||
request.status = 'unknown error'
|
request.status = 'unknown error'
|
||||||
request.statusCode = Craft.STATUS_ERROR
|
request.statusCode = Craft.STATUS_ERROR
|
||||||
@@ -108,21 +115,10 @@ local function machineCraft(recipe, qty, inventoryAdapter, machineName, oitem)
|
|||||||
end
|
end
|
||||||
request.status = 'processing'
|
request.status = 'processing'
|
||||||
request.statusCode = Craft.STATUS_INFO
|
request.statusCode = Craft.STATUS_INFO
|
||||||
request.pending = true
|
request.pending = count * recipe.count
|
||||||
end
|
end
|
||||||
|
|
||||||
local function turtleCraft(recipe, qty, inventoryAdapter, oitem)
|
local function turtleCraft(recipe, inventoryAdapter, request, count)
|
||||||
local key = recipe.result
|
|
||||||
local request = oitem.ingredients[key]
|
|
||||||
|
|
||||||
if not request then
|
|
||||||
request = {
|
|
||||||
count = qty,
|
|
||||||
crafted = 0,
|
|
||||||
}
|
|
||||||
oitem.ingredients[recipe.result] = request
|
|
||||||
end
|
|
||||||
|
|
||||||
if not clearGrid(inventoryAdapter) then
|
if not clearGrid(inventoryAdapter) then
|
||||||
request.status = 'grid in use'
|
request.status = 'grid in use'
|
||||||
request.statusCode = Craft.STATUS_ERROR
|
request.statusCode = Craft.STATUS_ERROR
|
||||||
@@ -131,92 +127,84 @@ local function turtleCraft(recipe, qty, inventoryAdapter, oitem)
|
|||||||
|
|
||||||
for k,v in pairs(recipe.ingredients) do
|
for k,v in pairs(recipe.ingredients) do
|
||||||
local item = splitKey(v)
|
local item = splitKey(v)
|
||||||
local provideQty = qty
|
if inventoryAdapter:provide(item, count, k) ~= count then
|
||||||
--[[
|
|
||||||
Turtles can only craft 1 item at a time when using a tool.
|
|
||||||
|
|
||||||
if recipe.craftingTools and recipe.craftingTools[k] then
|
|
||||||
provideQty = 1
|
|
||||||
end
|
|
||||||
]]--
|
|
||||||
if inventoryAdapter:provide(item, provideQty, k) ~= provideQty then
|
|
||||||
-- FIX: ingredients cannot be stacked
|
-- FIX: ingredients cannot be stacked
|
||||||
--debug('failed ' .. v .. ' - ' .. provideQty)
|
|
||||||
request.status = 'unknown error'
|
request.status = 'unknown error'
|
||||||
request.statusCode = Craft.STATUS_ERROR
|
request.statusCode = Craft.STATUS_ERROR
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
turtle.select(1)
|
||||||
if turtle.craft() then
|
if turtle.craft() then
|
||||||
request.status = nil
|
request.status = nil
|
||||||
request.statusCode = Craft.STATUS_SUCCESS
|
request.statusCode = Craft.STATUS_SUCCESS
|
||||||
|
request.crafted = request.crafted + count * recipe.count
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
request.status = 'failed to craft'
|
request.status = 'Failed to craft'
|
||||||
request.statusCode = Craft.STATUS_ERROR
|
request.statusCode = Craft.STATUS_ERROR
|
||||||
end
|
end
|
||||||
|
|
||||||
function Craft.loadRecipes()
|
|
||||||
Craft.recipes = { }
|
|
||||||
|
|
||||||
Util.merge(Craft.recipes, (Util.readTable(fs.combine(RECIPES_DIR, 'minecraft.db')) or { }).recipes)
|
|
||||||
|
|
||||||
local config = Util.readTable('usr/config/recipeBooks.db') or { }
|
|
||||||
for _, book in pairs(config) do
|
|
||||||
local recipeFile = Util.readTable(book)
|
|
||||||
Util.merge(Craft.recipes, recipeFile.recipes)
|
|
||||||
end
|
|
||||||
|
|
||||||
local recipes = Util.readTable(USER_RECIPES) or { }
|
|
||||||
Util.merge(Craft.recipes, recipes)
|
|
||||||
|
|
||||||
for k,v in pairs(Craft.recipes) do
|
|
||||||
v.result = k
|
|
||||||
end
|
|
||||||
|
|
||||||
Craft.machineLookup = Util.readTable(MACHINE_LOOKUP) or { }
|
|
||||||
end
|
|
||||||
|
|
||||||
function Craft.sumIngredients(recipe)
|
|
||||||
-- produces { ['minecraft:planks:0'] = 8 }
|
|
||||||
local t = { }
|
|
||||||
for _,item in pairs(recipe.ingredients) do
|
|
||||||
t[item] = (t[item] or 0) + 1
|
|
||||||
end
|
|
||||||
-- need a check for crafting tool
|
|
||||||
return t
|
|
||||||
end
|
|
||||||
|
|
||||||
local function makeRecipeKey(item)
|
|
||||||
if type(item) == 'string' then
|
|
||||||
item = splitKey(item)
|
|
||||||
end
|
|
||||||
return table.concat({ item.name, item.damage or 0, item.nbtHash }, ':')
|
|
||||||
end
|
|
||||||
|
|
||||||
function Craft.craftRecipe(recipe, count, inventoryAdapter, origItem)
|
function Craft.craftRecipe(recipe, count, inventoryAdapter, origItem)
|
||||||
if type(recipe) == 'string' then
|
if type(recipe) == 'string' then
|
||||||
recipe = Craft.recipes[recipe]
|
recipe = Craft.recipes[recipe]
|
||||||
if not recipe then
|
if not recipe then
|
||||||
origItem.ingredients[recipe.result] = {
|
|
||||||
status = 'no recipe',
|
|
||||||
statusCode = Craft.STATUS_ERROR,
|
|
||||||
}
|
|
||||||
return 0, 'No recipe'
|
return 0, 'No recipe'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
for _,key in pairs(Util.keys(origItem.ingredients)) do
|
||||||
|
local e = origItem.ingredients[key]
|
||||||
|
if e and e.transient then
|
||||||
|
origItem.ingredients[key] = nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return Craft.craftRecipeInternal(recipe, count, inventoryAdapter, origItem)
|
||||||
|
end
|
||||||
|
|
||||||
|
function Craft.craftRecipeInternal(recipe, count, inventoryAdapter, origItem)
|
||||||
local items = inventoryAdapter:listItems()
|
local items = inventoryAdapter:listItems()
|
||||||
if not items then
|
if not items then
|
||||||
origItem.ingredients[recipe.result] = {
|
|
||||||
status = 'Inventory changed',
|
|
||||||
statusCode = Craft.STATUS_ERROR,
|
|
||||||
}
|
|
||||||
return 0, 'Inventory changed'
|
return 0, 'Inventory changed'
|
||||||
end
|
end
|
||||||
|
|
||||||
count = math.ceil(count / recipe.count)
|
local request = origItem.ingredients[recipe.result]
|
||||||
|
if not request then
|
||||||
|
request = {
|
||||||
|
crafted = 0,
|
||||||
|
count = count,
|
||||||
|
}
|
||||||
|
origItem.ingredients[recipe.result] = request
|
||||||
|
end
|
||||||
|
|
||||||
|
if request.pending then
|
||||||
|
machineCraft(recipe, inventoryAdapter,
|
||||||
|
Craft.machineLookup[recipe.result], request)
|
||||||
|
return 0
|
||||||
|
end
|
||||||
|
|
||||||
|
local canCraft = Craft.getCraftableAmount(recipe, count, items, { })
|
||||||
|
if canCraft == 0 then
|
||||||
|
|
||||||
|
local resourceList = Craft.getResourceList(recipe, items, count)
|
||||||
|
for k,v in pairs(resourceList) do
|
||||||
|
if v.need > 0 then
|
||||||
|
if not origItem.ingredients[k] then
|
||||||
|
origItem.ingredients[k] = {
|
||||||
|
status = 'No recipe',
|
||||||
|
statusCode = Craft.STATUS_ERROR,
|
||||||
|
count = v.need,
|
||||||
|
crafted = 0,
|
||||||
|
transient = true,
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return 0
|
||||||
|
end
|
||||||
|
|
||||||
|
count = math.ceil(canCraft / recipe.count)
|
||||||
local maxCount = recipe.maxCount or math.floor(64 / recipe.count)
|
local maxCount = recipe.maxCount or math.floor(64 / recipe.count)
|
||||||
|
|
||||||
for key,icount in pairs(Craft.sumIngredients(recipe)) do
|
for key,icount in pairs(Craft.sumIngredients(recipe)) do
|
||||||
@@ -228,36 +216,33 @@ function Craft.craftRecipe(recipe, count, inventoryAdapter, origItem)
|
|||||||
maxCount = math.min(maxCount, itemDB:getMaxCount(key))
|
maxCount = math.min(maxCount, itemDB:getMaxCount(key))
|
||||||
if itemCount < need then
|
if itemCount < need then
|
||||||
local irecipe = Craft.findRecipe(key)
|
local irecipe = Craft.findRecipe(key)
|
||||||
if irecipe then
|
if not irecipe then
|
||||||
local iqty = need - itemCount
|
return 0
|
||||||
local crafted = Craft.craftRecipe(irecipe, iqty, inventoryAdapter, origItem)
|
end
|
||||||
if crafted ~= iqty then
|
local iqty = need - itemCount
|
||||||
turtle.select(1)
|
local crafted = Craft.craftRecipeInternal(irecipe, iqty, inventoryAdapter, origItem)
|
||||||
return 0
|
if crafted ~= iqty then
|
||||||
end
|
return 0
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local crafted = 0
|
local crafted = 0
|
||||||
repeat
|
repeat
|
||||||
local requested = math.min(count, maxCount)
|
local batch = math.min(count, maxCount)
|
||||||
|
|
||||||
if Craft.machineLookup[recipe.result] then
|
if Craft.machineLookup[recipe.result] then
|
||||||
if not machineCraft(recipe, requested, inventoryAdapter, Craft.machineLookup[recipe.result], origItem) then
|
if not machineCraft(recipe, inventoryAdapter,
|
||||||
break
|
Craft.machineLookup[recipe.result], request, batch) then
|
||||||
end
|
|
||||||
else
|
|
||||||
if not turtleCraft(recipe, requested, inventoryAdapter, origItem) then
|
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
|
elseif not turtleCraft(recipe, inventoryAdapter, request, batch) then
|
||||||
|
break
|
||||||
end
|
end
|
||||||
|
|
||||||
crafted = crafted + requested
|
crafted = crafted + batch
|
||||||
count = count - maxCount
|
count = count - maxCount
|
||||||
until count <= 0
|
until count <= 0
|
||||||
|
|
||||||
turtle.select(1)
|
|
||||||
return crafted * recipe.count
|
return crafted * recipe.count
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -378,6 +363,27 @@ function Craft.getCraftableAmount(inRecipe, count, items, missing)
|
|||||||
return sumItems(inRecipe, { }, math.ceil(count / inRecipe.count))
|
return sumItems(inRecipe, { }, math.ceil(count / inRecipe.count))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function Craft.loadRecipes()
|
||||||
|
Craft.recipes = { }
|
||||||
|
|
||||||
|
Util.merge(Craft.recipes, (Util.readTable(fs.combine(RECIPES_DIR, 'minecraft.db')) or { }).recipes)
|
||||||
|
|
||||||
|
local config = Util.readTable('usr/config/recipeBooks.db') or { }
|
||||||
|
for _, book in pairs(config) do
|
||||||
|
local recipeFile = Util.readTable(book)
|
||||||
|
Util.merge(Craft.recipes, recipeFile.recipes)
|
||||||
|
end
|
||||||
|
|
||||||
|
local recipes = Util.readTable(USER_RECIPES) or { }
|
||||||
|
Util.merge(Craft.recipes, recipes)
|
||||||
|
|
||||||
|
for k,v in pairs(Craft.recipes) do
|
||||||
|
v.result = k
|
||||||
|
end
|
||||||
|
|
||||||
|
Craft.machineLookup = Util.readTable(MACHINE_LOOKUP) or { }
|
||||||
|
end
|
||||||
|
|
||||||
function Craft.canCraft(item, count, items)
|
function Craft.canCraft(item, count, items)
|
||||||
return Craft.getCraftableAmount(Craft.recipes[item], count, items) == count
|
return Craft.getCraftableAmount(Craft.recipes[item], count, items) == count
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -10,17 +10,9 @@ local craftTask = {
|
|||||||
priority = 70,
|
priority = 70,
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Craft
|
function craftTask:craftItem(recipe, item, count)
|
||||||
function craftTask:craftItem(recipe, originalItem, count)
|
Craft.craftRecipe(recipe, count, context.inventoryAdapter, item)
|
||||||
local toCraft = Craft.getCraftableAmount(recipe, count, Milo:listItems(), { })
|
Milo:clearGrid()
|
||||||
local crafted = 0
|
|
||||||
|
|
||||||
if toCraft > 0 then
|
|
||||||
crafted = Craft.craftRecipe(recipe, toCraft, context.inventoryAdapter, originalItem)
|
|
||||||
Milo:clearGrid()
|
|
||||||
end
|
|
||||||
|
|
||||||
return crafted
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Craft as much as possible regardless if all ingredients are available
|
-- Craft as much as possible regardless if all ingredients are available
|
||||||
@@ -91,24 +83,21 @@ function craftTask:forceCraftItem(inRecipe, originalItem, inCount)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function craftTask:craft(recipe, item)
|
function craftTask:craft(recipe, item)
|
||||||
item.status = nil
|
|
||||||
item.statusCode = nil
|
|
||||||
|
|
||||||
if Milo:isCraftingPaused() then
|
if Milo:isCraftingPaused() then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if item.forceCrafting then
|
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
|
else
|
||||||
item.crafted = item.crafted + self:craftItem(recipe, item, item.count - item.crafted)
|
self:craftItem(recipe, item, item.count - item.crafted)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function craftTask:cycle()
|
function craftTask:cycle()
|
||||||
for _,key in pairs(Util.keys(context.craftingQueue)) do
|
for _,key in pairs(Util.keys(context.craftingQueue)) do
|
||||||
local item = context.craftingQueue[key]
|
local item = context.craftingQueue[key]
|
||||||
if item.count > 0 then
|
if item.count - item.crafted > 0 then
|
||||||
local recipe = Craft.recipes[key]
|
local recipe = Craft.recipes[key]
|
||||||
if recipe then
|
if recipe then
|
||||||
self:craft(recipe, item)
|
self:craft(recipe, item)
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ local jobList = UI.Page {
|
|||||||
sortColumn = 'index',
|
sortColumn = 'index',
|
||||||
backgroundFocusColor = colors.black,
|
backgroundFocusColor = colors.black,
|
||||||
columns = {
|
columns = {
|
||||||
{ heading = 'Qty', key = 'remaining', width = 6 },
|
{ heading = 'Qty', key = 'remaining', width = 4 },
|
||||||
{ heading = 'Crafting', key = 'displayName', },
|
{ heading = 'Crafting', key = 'displayName', },
|
||||||
{ heading = 'Status', key = 'status', },
|
{ heading = 'Status', key = 'status', },
|
||||||
{ heading = 'Req', key = 'count', width = 3 },
|
{ heading = 'Req', key = 'count', width = 3 },
|
||||||
@@ -41,13 +41,15 @@ function jobList:updateList(craftList)
|
|||||||
for _,v in pairs(craftList) do
|
for _,v in pairs(craftList) do
|
||||||
table.insert(t, v)
|
table.insert(t, v)
|
||||||
v.index = #t
|
v.index = #t
|
||||||
v.showRemining = true
|
v.showRemaining = true
|
||||||
for k2,v2 in pairs(v.ingredients) do
|
for k2,v2 in pairs(v.ingredients) do
|
||||||
table.insert(t, v2)
|
if v2 ~= v then
|
||||||
if not v2.displayName then
|
table.insert(t, v2)
|
||||||
v2.displayName = itemDB:getName(k2)
|
if not v2.displayName then
|
||||||
|
v2.displayName = itemDB:getName(k2)
|
||||||
|
end
|
||||||
|
v2.index = #t
|
||||||
end
|
end
|
||||||
v2.index = #t
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
self.grid:setValues(t)
|
self.grid:setValues(t)
|
||||||
@@ -59,8 +61,10 @@ end
|
|||||||
|
|
||||||
function jobList.grid:getDisplayValues(row)
|
function jobList.grid:getDisplayValues(row)
|
||||||
row = Util.shallowCopy(row)
|
row = Util.shallowCopy(row)
|
||||||
if row.showRemining then
|
if row.showRemaining then
|
||||||
row.remaining = row.count - row.crafted
|
row.remaining = row.count - row.crafted
|
||||||
|
else
|
||||||
|
row.displayName = ' ' .. row.displayName
|
||||||
end
|
end
|
||||||
return row
|
return row
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -116,6 +116,8 @@ function pages.confirmation:validate()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- TODO: maxCount needs to be entered by user ? ie. brewing station can only do 1 at a time
|
||||||
|
|
||||||
local recipe = {
|
local recipe = {
|
||||||
count = result.count,
|
count = result.count,
|
||||||
ingredients = { },
|
ingredients = { },
|
||||||
@@ -131,12 +133,13 @@ function pages.confirmation:validate()
|
|||||||
-- save the recipe
|
-- save the recipe
|
||||||
context.userRecipes[key] = recipe
|
context.userRecipes[key] = recipe
|
||||||
Util.writeTable(Milo.RECIPES_FILE, context.userRecipes)
|
Util.writeTable(Milo.RECIPES_FILE, context.userRecipes)
|
||||||
Craft.loadRecipes()
|
|
||||||
|
|
||||||
-- save the machine association
|
-- save the machine association
|
||||||
Craft.machineLookup[key] = machine.name
|
Craft.machineLookup[key] = machine.name
|
||||||
Util.writeTable(MACHINE_LOOKUP, Craft.machineLookup)
|
Util.writeTable(MACHINE_LOOKUP, Craft.machineLookup)
|
||||||
|
|
||||||
|
Craft.loadRecipes()
|
||||||
|
|
||||||
local listingPage = UI:getPage('listing')
|
local listingPage = UI:getPage('listing')
|
||||||
local displayName = itemDB:getName(result)
|
local displayName = itemDB:getName(result)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user