fix crafting bug - missing ingredients

This commit is contained in:
kepler155c@gmail.com
2019-01-06 04:15:36 -05:00
parent 1164bec812
commit 6ac9816189
2 changed files with 28 additions and 29 deletions

View File

@@ -476,7 +476,7 @@ local function findDroppedSaplings()
local sensed = Util.reduce(raw, function(acc, b) local sensed = Util.reduce(raw, function(acc, b)
Point.rotate(b, state.home.heading) Point.rotate(b, state.home.heading)
b.x = Util.round(b.x) + turtle.point.x b.x = Util.round(b.x) + turtle.point.x
b.y = Util.round(b.y) + turtle.point.y b.y = math.floor(b.y) + turtle.point.y
b.z = Util.round(b.z) + turtle.point.z b.z = Util.round(b.z) + turtle.point.z
if b.y == 0 and string.find(b.displayName, 'sapling', 1, true) then if b.y == 0 and string.find(b.displayName, 'sapling', 1, true) then
b.sapling = true b.sapling = true

View File

@@ -191,14 +191,6 @@ local function adjustCounts(recipe, count, ingredients, storage)
-- decrement ingredients used -- decrement ingredients used
for key,icount in pairs(Craft.sumIngredients(recipe)) do for key,icount in pairs(Craft.sumIngredients(recipe)) do
ingredients[key].count = ingredients[key].count - (icount * count) ingredients[key].count = ingredients[key].count - (icount * count)
if ingredients[key].count == 0 and not storage.cache[key] then
--
elseif not storage.cache[key] then
_debug({ key, ingredients[key].count, 'nocache' })
elseif storage.cache[key].count ~= ingredients[key].count then
_debug({ key, ingredients[key].count, storage.cache[key].count })
end
end end
-- increment crafted -- increment crafted
@@ -232,6 +224,9 @@ function Craft.craftRecipeInternal(recipe, count, storage, origItem)
--local maxCount = math.floor((recipe.maxCount or 64) / recipe.count) --local maxCount = math.floor((recipe.maxCount or 64) / recipe.count)
local maxCount = recipe.maxCount or math.floor(64 / recipe.count) local maxCount = recipe.maxCount or math.floor(64 / recipe.count)
repeat
local craftedIngredient
for key,icount in pairs(Craft.sumIngredients(recipe)) do for key,icount in pairs(Craft.sumIngredients(recipe)) do
local itemCount = Craft.getItemCount(origItem.ingredients, key) local itemCount = Craft.getItemCount(origItem.ingredients, key)
local need = icount * count local need = icount * count
@@ -253,9 +248,13 @@ function Craft.craftRecipeInternal(recipe, count, storage, origItem)
if origItem.forceCrafting and crafted < iqty then if origItem.forceCrafting and crafted < iqty then
canCraft = math.floor((itemCount + crafted) / icount) canCraft = math.floor((itemCount + crafted) / icount)
end end
if crafted > 0 then
craftedIngredient = true
end end
end end
_G._p = origItem.ingredients end
until not craftedIngredient
local crafted = 0 local crafted = 0
while canCraft > 0 do while canCraft > 0 do
local batch = math.min(canCraft, maxCount) local batch = math.min(canCraft, maxCount)