rework milo crafting
This commit is contained in:
@@ -23,11 +23,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 = {
|
|
||||||
[ key ] = item
|
|
||||||
}
|
|
||||||
item.crafted = 0
|
item.crafted = 0
|
||||||
|
item.pending = { }
|
||||||
|
item.key = key
|
||||||
self.context.craftingQueue[key] = item
|
self.context.craftingQueue[key] = item
|
||||||
|
os.queueEvent('milo_cycle')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -27,12 +27,12 @@ listCount = 0,
|
|||||||
self.localName = modem.getNameLocal()
|
self.localName = modem.getNameLocal()
|
||||||
|
|
||||||
Event.on({ 'device_attach', 'device_detach' }, function(e, dev)
|
Event.on({ 'device_attach', 'device_detach' }, function(e, dev)
|
||||||
_debug('%s: %s', e, tostring(dev))
|
--_debug('%s: %s', e, tostring(dev))
|
||||||
self:initStorage()
|
self:initStorage()
|
||||||
end)
|
end)
|
||||||
Event.onInterval(15, function()
|
Event.onInterval(15, function()
|
||||||
self:showStorage()
|
self:showStorage()
|
||||||
_debug('STORAGE: cache: %d/%d', self.hits, self.misses)
|
-- _debug('STORAGE: cache: %d/%d', self.hits, self.misses)
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -202,9 +202,9 @@ function Storage:provide(item, qty, slot, direction)
|
|||||||
local amount = adapter:provide(item, qty, slot, direction or self.localName)
|
local amount = adapter:provide(item, qty, slot, direction or self.localName)
|
||||||
if amount > 0 then
|
if amount > 0 then
|
||||||
self.hits = self.hits + 1
|
self.hits = self.hits + 1
|
||||||
_debug('EXT: %s(%d): %s -> %s%s',
|
-- _debug('EXT: %s(%d): %s -> %s%s',
|
||||||
item.name, amount, adapter.name, direction or self.localName,
|
-- item.name, amount, adapter.name, direction or self.localName,
|
||||||
slot and string.format('[%d]', slot) or '')
|
-- slot and string.format('[%d]', slot) or '')
|
||||||
self.dirty = true
|
self.dirty = true
|
||||||
adapter.dirty = true
|
adapter.dirty = true
|
||||||
end
|
end
|
||||||
@@ -222,9 +222,9 @@ function Storage:provide(item, qty, slot, direction)
|
|||||||
for _, adapter in self:onlineAdapters() do
|
for _, adapter in self:onlineAdapters() do
|
||||||
local amount = adapter:provide(item, qty, slot, direction or self.localName)
|
local amount = adapter:provide(item, qty, slot, direction or self.localName)
|
||||||
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, adapter.name, direction or self.localName,
|
-- item.name, amount, adapter.name, direction or self.localName,
|
||||||
slot and string.format('[%d]', slot) or '')
|
-- slot and string.format('[%d]', slot) or '')
|
||||||
self.dirty = true
|
self.dirty = true
|
||||||
adapter.dirty = true
|
adapter.dirty = true
|
||||||
end
|
end
|
||||||
@@ -241,8 +241,8 @@ end
|
|||||||
function Storage:trash(source, slot, count)
|
function Storage:trash(source, slot, count)
|
||||||
local trashcan = Util.find(self.remoteDefaults, 'mtype', 'trashcan')
|
local trashcan = Util.find(self.remoteDefaults, 'mtype', 'trashcan')
|
||||||
if trashcan and trashcan.adapter and trashcan.adapter.online then
|
if trashcan and trashcan.adapter and trashcan.adapter.online then
|
||||||
_debug('TRA: %s[%d] (%d)', source or self.localName, slot, count or 64)
|
--_debug('TRA: %s[%d] (%d)', source or self.localName, slot, count or 64)
|
||||||
return trashcan.adapter.pullItems(source or self.localName, slot, count)
|
-- return trashcan.adapter.pullItems(source or self.localName, slot, count)
|
||||||
end
|
end
|
||||||
return 0
|
return 0
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -73,23 +73,10 @@ function Craft.sumIngredients(recipe)
|
|||||||
for _,item in pairs(recipe.ingredients) do
|
for _,item in pairs(recipe.ingredients) do
|
||||||
t[item] = (t[item] or 0) + 1
|
t[item] = (t[item] or 0) + 1
|
||||||
end
|
end
|
||||||
-- need a check for crafting tool
|
|
||||||
return t
|
return t
|
||||||
end
|
end
|
||||||
|
|
||||||
local function machineCraft(recipe, inventoryAdapter, machineName, request, count)
|
local function machineCraft(recipe, inventoryAdapter, machineName, request, count, item)
|
||||||
if request.pending then
|
|
||||||
local imported = (inventoryAdapter.activity[recipe.result] or 0)
|
|
||||||
request.pending = request.pending - imported
|
|
||||||
request.crafted = request.crafted + imported
|
|
||||||
if request.pending <= 0 then
|
|
||||||
request.pending = nil
|
|
||||||
request.statusCode = nil
|
|
||||||
request.status = nil
|
|
||||||
end
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local machine = device[machineName]
|
local machine = device[machineName]
|
||||||
if not machine then
|
if not machine then
|
||||||
request.status = 'machine not found'
|
request.status = 'machine not found'
|
||||||
@@ -126,7 +113,7 @@ local function machineCraft(recipe, inventoryAdapter, machineName, request, coun
|
|||||||
end
|
end
|
||||||
request.status = 'processing'
|
request.status = 'processing'
|
||||||
request.statusCode = Craft.STATUS_INFO
|
request.statusCode = Craft.STATUS_INFO
|
||||||
request.pending = count * recipe.count
|
item.pending[recipe.result] = count * recipe.count
|
||||||
end
|
end
|
||||||
|
|
||||||
local function turtleCraft(recipe, inventoryAdapter, request, count)
|
local function turtleCraft(recipe, inventoryAdapter, request, count)
|
||||||
@@ -149,12 +136,28 @@ local function turtleCraft(recipe, inventoryAdapter, request, count)
|
|||||||
turtle.select(1)
|
turtle.select(1)
|
||||||
if turtle.craft() then
|
if turtle.craft() then
|
||||||
request.crafted = request.crafted + count * recipe.count
|
request.crafted = request.crafted + count * recipe.count
|
||||||
|
request.status = 'crafted'
|
||||||
|
request.statusCode = Craft.STATUS_INFO
|
||||||
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.processPending(item, inventoryAdapter)
|
||||||
|
for key, count in pairs(item.pending) do
|
||||||
|
local imported = inventoryAdapter.activity[key]
|
||||||
|
if imported then
|
||||||
|
local amount = math.min(imported, count)
|
||||||
|
inventoryAdapter.activity[key] = imported - amount
|
||||||
|
item.pending[key] = count - amount
|
||||||
|
if item.pending[key] <= 0 then
|
||||||
|
item.pending[key] = nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
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]
|
||||||
@@ -163,89 +166,43 @@ function Craft.craftRecipe(recipe, count, inventoryAdapter, origItem)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- wait til all requests have been completed
|
local crafted = Craft.craftRecipeInternal(recipe, count, inventoryAdapter, origItem)
|
||||||
local isPending = false
|
|
||||||
for key, request in pairs(origItem.ingredients) do
|
|
||||||
if request.pending then
|
|
||||||
local irecipe = Craft.findRecipe(key)
|
|
||||||
machineCraft(irecipe, inventoryAdapter,
|
|
||||||
Craft.machineLookup[irecipe.result], request)
|
|
||||||
isPending = request.pending or isPending
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local crafted = 0
|
origItem.crafted = math.min(origItem.count, origItem.crafted + crafted)
|
||||||
--if not isPending then
|
|
||||||
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
|
|
||||||
crafted = Craft.craftRecipeInternal(recipe, count, inventoryAdapter, origItem)
|
|
||||||
--end
|
|
||||||
|
|
||||||
for _, request in pairs(origItem.ingredients) do
|
|
||||||
if request.crafted >= request.count then
|
|
||||||
if request.pending then
|
|
||||||
_debug('??')
|
|
||||||
_debug(request)
|
|
||||||
end
|
|
||||||
request.status = nil
|
|
||||||
request.statusCode = Craft.STATUS_SUCCESS
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
return crafted
|
return crafted
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function adjustCounts(recipe, count, ingredients)
|
||||||
|
-- decrement ingredients used
|
||||||
|
for key,icount in pairs(Craft.sumIngredients(recipe)) do
|
||||||
|
ingredients[key].count = ingredients[key].count - (icount * count)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- increment crafted
|
||||||
|
local result = ingredients[recipe.result]
|
||||||
|
result.count = result.count + (count * recipe.count)
|
||||||
|
end
|
||||||
|
|
||||||
function Craft.craftRecipeInternal(recipe, count, inventoryAdapter, origItem)
|
function Craft.craftRecipeInternal(recipe, count, inventoryAdapter, origItem)
|
||||||
local items = inventoryAdapter:listItems()
|
|
||||||
if not items then
|
|
||||||
return 0, 'Inventory changed'
|
|
||||||
end
|
|
||||||
|
|
||||||
local request = origItem.ingredients[recipe.result]
|
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
|
local canCraft = Craft.getCraftableAmount(recipe, count, origItem.ingredients)
|
||||||
--machineCraft(recipe, inventoryAdapter,
|
if not origItem.forceCrafting and canCraft == 0 then
|
||||||
-- Craft.machineLookup[recipe.result], request)
|
|
||||||
return 0
|
return 0
|
||||||
end
|
end
|
||||||
|
|
||||||
local canCraft = Craft.getCraftableAmount(recipe, count, items, { })
|
canCraft = math.ceil(canCraft / recipe.count)
|
||||||
if canCraft == 0 then
|
if origItem.forceCrafting then
|
||||||
|
count = math.ceil(count / recipe.count)
|
||||||
local resourceList = Craft.getResourceList(recipe, items, count)
|
else
|
||||||
_G._p2 = resourceList
|
count = canCraft
|
||||||
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
|
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
|
||||||
local itemCount = Craft.getItemCount(items, key)
|
local itemCount = Craft.getItemCount(origItem.ingredients, key)
|
||||||
local need = icount * count
|
local need = icount * count
|
||||||
if recipe.craftingTools and recipe.craftingTools[key] then
|
if recipe.craftingTools and recipe.craftingTools[key] then
|
||||||
need = 1
|
need = 1
|
||||||
@@ -258,27 +215,40 @@ _G._p2 = resourceList
|
|||||||
end
|
end
|
||||||
local iqty = need - itemCount
|
local iqty = need - itemCount
|
||||||
local crafted = Craft.craftRecipeInternal(irecipe, iqty, inventoryAdapter, origItem)
|
local crafted = Craft.craftRecipeInternal(irecipe, iqty, inventoryAdapter, origItem)
|
||||||
if crafted ~= iqty then
|
if not origItem.forceCrafting and crafted < iqty then
|
||||||
return 0
|
return 0
|
||||||
end
|
end
|
||||||
|
if origItem.forceCrafting and crafted < iqty then
|
||||||
|
canCraft = math.floor((itemCount + crafted) / icount)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
local crafted = 0
|
local crafted = 0
|
||||||
repeat
|
while canCraft > 0 do
|
||||||
local batch = math.min(count, maxCount)
|
if origItem.pending[recipe.result] then
|
||||||
|
request.status = 'processing'
|
||||||
|
request.statusCode = Craft.STATUS_INFO
|
||||||
|
break
|
||||||
|
end
|
||||||
|
|
||||||
|
local batch = math.min(canCraft, maxCount)
|
||||||
|
|
||||||
if Craft.machineLookup[recipe.result] then
|
if Craft.machineLookup[recipe.result] then
|
||||||
if not machineCraft(recipe, inventoryAdapter,
|
if not machineCraft(recipe, inventoryAdapter,
|
||||||
Craft.machineLookup[recipe.result], request, batch) then
|
Craft.machineLookup[recipe.result], request, batch, origItem) then
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
elseif not turtleCraft(recipe, inventoryAdapter, request, batch) then
|
elseif not turtleCraft(recipe, inventoryAdapter, request, batch) then
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
|
|
||||||
|
adjustCounts(recipe, batch, origItem.ingredients)
|
||||||
|
|
||||||
crafted = crafted + batch
|
crafted = crafted + batch
|
||||||
count = count - maxCount
|
canCraft = canCraft - maxCount
|
||||||
until count <= 0
|
end
|
||||||
|
|
||||||
return crafted * recipe.count
|
return crafted * recipe.count
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ local page = UI.Window {
|
|||||||
textScale = .5,
|
textScale = .5,
|
||||||
},
|
},
|
||||||
grid = UI.Grid {
|
grid = UI.Grid {
|
||||||
ey = -6,
|
|
||||||
columns = {
|
columns = {
|
||||||
{ heading = 'Qty', key = 'count', width = 6 },
|
{ heading = 'Qty', key = 'count', width = 6 },
|
||||||
{ heading = 'Change', key = 'change', width = 6 },
|
{ heading = 'Change', key = 'change', width = 6 },
|
||||||
@@ -28,31 +27,6 @@ local page = UI.Window {
|
|||||||
},
|
},
|
||||||
sortColumn = 'displayName',
|
sortColumn = 'displayName',
|
||||||
},
|
},
|
||||||
buttons = UI.Window {
|
|
||||||
y = -5, height = 5,
|
|
||||||
backgroundColor = colors.gray,
|
|
||||||
prevButton = UI.Button {
|
|
||||||
x = 2, y = 2, height = 3, width = 5,
|
|
||||||
event = 'previous',
|
|
||||||
backgroundColor = colors.lightGray,
|
|
||||||
text = ' < '
|
|
||||||
},
|
|
||||||
resetButton = UI.Button {
|
|
||||||
x = 8, y = 2, height = 3, ex = -8,
|
|
||||||
event = 'reset',
|
|
||||||
backgroundColor = colors.lightGray,
|
|
||||||
text = 'Reset'
|
|
||||||
},
|
|
||||||
nextButton = UI.Button {
|
|
||||||
x = -6, y = 2, height = 3, width = 5,
|
|
||||||
event = 'next',
|
|
||||||
backgroundColor = colors.lightGray,
|
|
||||||
text = ' > '
|
|
||||||
},
|
|
||||||
},
|
|
||||||
accelerators = {
|
|
||||||
q = 'quit',
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function page.grid:getRowTextColor(row, selected)
|
function page.grid:getRowTextColor(row, selected)
|
||||||
@@ -77,27 +51,11 @@ function page.grid:getDisplayValues(row)
|
|||||||
return row
|
return row
|
||||||
end
|
end
|
||||||
|
|
||||||
function page:eventHandler(event)
|
function page:reset()
|
||||||
if event.type == 'reset' then
|
self.lastItems = nil
|
||||||
self.lastItems = nil
|
self.grid:setValues({ })
|
||||||
self.grid:setValues({ })
|
self.grid:clear()
|
||||||
self.grid:clear()
|
self.grid:draw()
|
||||||
self.grid:draw()
|
|
||||||
|
|
||||||
elseif event.type == 'next' then
|
|
||||||
self.grid:nextPage()
|
|
||||||
|
|
||||||
elseif event.type == 'previous' then
|
|
||||||
self.grid:previousPage()
|
|
||||||
|
|
||||||
elseif event.type == 'quit' then
|
|
||||||
Event.exitPullEvents()
|
|
||||||
|
|
||||||
else
|
|
||||||
return UI.Window.eventHandler(self, event)
|
|
||||||
end
|
|
||||||
|
|
||||||
return true
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function page:refresh()
|
function page:refresh()
|
||||||
@@ -165,7 +123,7 @@ end)
|
|||||||
|
|
||||||
Event.on('monitor_touch', function(_, side)
|
Event.on('monitor_touch', function(_, side)
|
||||||
if side == mon.side then
|
if side == mon.side then
|
||||||
page:emit({ type = 'reset' })
|
page:reset()
|
||||||
page:sync()
|
page:sync()
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
local Craft = require('turtle.craft')
|
local Craft = require('turtle.craft')
|
||||||
local itemDB = require('itemDB')
|
|
||||||
local Milo = require('milo')
|
local Milo = require('milo')
|
||||||
local sync = require('sync').sync
|
local sync = require('sync').sync
|
||||||
local Util = require('util')
|
local Util = require('util')
|
||||||
@@ -12,89 +11,30 @@ local craftTask = {
|
|||||||
priority = 70,
|
priority = 70,
|
||||||
}
|
}
|
||||||
|
|
||||||
function craftTask:craftItem(recipe, item, count)
|
|
||||||
Craft.craftRecipe(recipe, count, context.storage, item)
|
|
||||||
Milo:clearGrid()
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Craft as much as possible regardless if all ingredients are available
|
|
||||||
function craftTask:forceCraftItem(inRecipe, originalItem, inCount)
|
|
||||||
local summed = { }
|
|
||||||
local items = Milo:listItems()
|
|
||||||
local throttle = Util.throttle()
|
|
||||||
|
|
||||||
local function sumItems(recipe, count)
|
|
||||||
count = math.ceil(count / recipe.count)
|
|
||||||
local craftable = count
|
|
||||||
|
|
||||||
for key,iqty in pairs(Craft.sumIngredients(recipe)) do
|
|
||||||
throttle()
|
|
||||||
local item = itemDB:splitKey(key)
|
|
||||||
local summedItem = summed[key]
|
|
||||||
if not summedItem then
|
|
||||||
summedItem = Util.shallowCopy(item)
|
|
||||||
summedItem.recipe = Craft.findRecipe(item)
|
|
||||||
summedItem.count = Craft.getItemCount(items, key)
|
|
||||||
summedItem.need = 0
|
|
||||||
summedItem.used = 0
|
|
||||||
summedItem.craftable = 0
|
|
||||||
summed[key] = summedItem
|
|
||||||
end
|
|
||||||
|
|
||||||
local total = count * iqty -- 4 * 2
|
|
||||||
local used = math.min(summedItem.count, total) -- 5
|
|
||||||
local need = total - used -- 3
|
|
||||||
|
|
||||||
if recipe.craftingTools and recipe.craftingTools[key] then
|
|
||||||
if summedItem.count > 0 then
|
|
||||||
summedItem.used = 1
|
|
||||||
summedItem.need = 0
|
|
||||||
need = 0
|
|
||||||
elseif not summedItem.recipe then
|
|
||||||
summedItem.need = 1
|
|
||||||
need = 1
|
|
||||||
else
|
|
||||||
need = 1
|
|
||||||
end
|
|
||||||
else
|
|
||||||
summedItem.count = summedItem.count - used
|
|
||||||
summedItem.used = summedItem.used + used
|
|
||||||
end
|
|
||||||
|
|
||||||
if need > 0 then
|
|
||||||
if not summedItem.recipe then
|
|
||||||
craftable = math.min(craftable, math.floor(used / iqty))
|
|
||||||
summedItem.need = summedItem.need + need
|
|
||||||
else
|
|
||||||
local c = sumItems(summedItem.recipe, need) -- 4
|
|
||||||
craftable = math.min(craftable, math.floor((used + c) / iqty))
|
|
||||||
summedItem.craftable = summedItem.craftable + c
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if craftable > 0 then
|
|
||||||
craftable = Craft.craftRecipe(recipe, craftable * recipe.count,
|
|
||||||
context.storage, originalItem) / recipe.count
|
|
||||||
Milo:clearGrid()
|
|
||||||
end
|
|
||||||
|
|
||||||
return craftable * recipe.count
|
|
||||||
end
|
|
||||||
|
|
||||||
return sumItems(inRecipe, inCount)
|
|
||||||
end
|
|
||||||
|
|
||||||
function craftTask:craft(recipe, item)
|
function craftTask:craft(recipe, item)
|
||||||
if Milo:isCraftingPaused() then
|
if Milo:isCraftingPaused() then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if item.forceCrafting then
|
Craft.processPending(item, context.storage)
|
||||||
self:forceCraftItem(recipe, item, item.count - item.crafted)
|
|
||||||
else
|
item.ingredients = Craft.getResourceList(recipe, Milo:listItems(), item.count - item.crafted)
|
||||||
self:craftItem(recipe, item, item.count - item.crafted)
|
|
||||||
|
for k, v in pairs(item.ingredients) do
|
||||||
|
v.crafted = v.used
|
||||||
|
v.count = v.used
|
||||||
|
v.key = k
|
||||||
|
if v.need > 0 then
|
||||||
|
v.status = 'No recipe'
|
||||||
|
v.statusCode = Craft.STATUS_ERROR
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
item.ingredients[recipe.result] = Util.shallowCopy(item)
|
||||||
|
item.ingredients[recipe.result].total = item.count
|
||||||
|
item.ingredients[recipe.result].crafted = item.crafted
|
||||||
|
|
||||||
|
Craft.craftRecipe(recipe, item.count - item.crafted, context.storage, item)
|
||||||
|
Milo:clearGrid()
|
||||||
end
|
end
|
||||||
|
|
||||||
function craftTask:cycle()
|
function craftTask:cycle()
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ function craftPage.wizard.pages.resources:enable()
|
|||||||
local count = tonumber(self.parent.quantity.count.value)
|
local count = tonumber(self.parent.quantity.count.value)
|
||||||
local recipe = Craft.findRecipe(craftPage.item)
|
local recipe = Craft.findRecipe(craftPage.item)
|
||||||
if recipe then
|
if recipe then
|
||||||
local ingredients = Craft.getResourceList4(recipe, items, count)
|
local ingredients = Craft.getResourceList(recipe, items, count)
|
||||||
for _,v in pairs(ingredients) do
|
for _,v in pairs(ingredients) do
|
||||||
v.displayName = itemDB:getName(v)
|
v.displayName = itemDB:getName(v)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -25,7 +25,12 @@ local jobMonitor = UI.Page {
|
|||||||
{ heading = 'Qty', key = 'remaining', width = 4 },
|
{ heading = 'Qty', key = 'remaining', width = 4 },
|
||||||
{ heading = 'Crafting', key = 'displayName', },
|
{ heading = 'Crafting', key = 'displayName', },
|
||||||
{ heading = 'Status', key = 'status', },
|
{ heading = 'Status', key = 'status', },
|
||||||
{ heading = 'Progress', key = 'progress', width = 8 },
|
{ heading = 'need', key = 'need', width = 4 },
|
||||||
|
{ heading = 'total', key = 'total', width = 4 },
|
||||||
|
{ heading = 'used', key = 'used', width = 4 },
|
||||||
|
{ heading = 'count', key = 'count', width = 4 },
|
||||||
|
{ heading = 'crafted', key = 'crafted', width = 4 },
|
||||||
|
-- { heading = 'Progress', key = 'progress', width = 8 },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@@ -44,7 +49,7 @@ function jobMonitor:updateList(craftList)
|
|||||||
v.index = #t
|
v.index = #t
|
||||||
v.showRemaining = true
|
v.showRemaining = true
|
||||||
for k2,v2 in pairs(v.ingredients) do
|
for k2,v2 in pairs(v.ingredients) do
|
||||||
if v2 ~= v then
|
if v2.key ~= v.key and v2.statusCode then
|
||||||
table.insert(t, v2)
|
table.insert(t, v2)
|
||||||
if not v2.displayName then
|
if not v2.displayName then
|
||||||
v2.displayName = itemDB:getName(k2)
|
v2.displayName = itemDB:getName(k2)
|
||||||
|
|||||||
@@ -425,10 +425,6 @@ local function scan()
|
|||||||
page.statusBar:setValue('status', b.name .. ' ' .. m)
|
page.statusBar:setValue('status', b.name .. ' ' .. m)
|
||||||
page.statusBar:draw()
|
page.statusBar:draw()
|
||||||
page:sync()
|
page:sync()
|
||||||
if debug and type(debug) == 'function' then
|
|
||||||
debug(b.name .. ' ' .. m)
|
|
||||||
end
|
|
||||||
-- os.sleep(3)
|
|
||||||
else
|
else
|
||||||
page.statusBar:setValue('mining', m)
|
page.statusBar:setValue('mining', m)
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user