fix: get to a working state
This commit is contained in:
parent
28e72b142f
commit
0f1ace9116
1 changed files with 7 additions and 5 deletions
|
|
@ -101,7 +101,7 @@ function cycleItems (ticker, items)
|
||||||
local makeRequest
|
local makeRequest
|
||||||
makeRequest = function (item, amt, addr)
|
makeRequest = function (item, amt, addr)
|
||||||
local limit = 64
|
local limit = 64
|
||||||
if addr = MELTER_ADDR then limit = 9 end
|
if addr == MELTER_ADDR then limit = 9 end
|
||||||
if amt < limit then return end
|
if amt < limit then return end
|
||||||
local request = {
|
local request = {
|
||||||
name = item,
|
name = item,
|
||||||
|
|
@ -109,7 +109,7 @@ function cycleItems (ticker, items)
|
||||||
}
|
}
|
||||||
ticker.requestFiltered(addr, request)
|
ticker.requestFiltered(addr, request)
|
||||||
os.sleep(1)
|
os.sleep(1)
|
||||||
return makeRequest(item, amt - limit)
|
return makeRequest(item, amt - limit, addr)
|
||||||
end
|
end
|
||||||
for _, pair in pairs(PRODUCTS) do
|
for _, pair in pairs(PRODUCTS) do
|
||||||
local name, addr = pair[1], pair[2]
|
local name, addr = pair[1], pair[2]
|
||||||
|
|
@ -142,20 +142,22 @@ function getNumCraftable (recipe, current_stock)
|
||||||
result = math.min(result, num)
|
result = math.min(result, num)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
if result == nil then result = 0 end
|
||||||
return result
|
return result
|
||||||
end
|
end
|
||||||
|
|
||||||
function craftRecipe (ticker, recipe, count)
|
function craftRecipe (ticker, recipe, count)
|
||||||
if count == nil then count = 1 end
|
if count == nil then count = 1 end
|
||||||
local createRequest
|
local createRequest
|
||||||
createRequest = function (recipe)
|
createRequest = function (recipe, i)
|
||||||
local ingredient = table.remove(recipe)
|
if i == nil then i = 1 end
|
||||||
|
local ingredient = recipe[i]
|
||||||
if ingredient == nil then return end
|
if ingredient == nil then return end
|
||||||
local item = {
|
local item = {
|
||||||
name = ingredient[1],
|
name = ingredient[1],
|
||||||
_requestCount = ingredient[2],
|
_requestCount = ingredient[2],
|
||||||
}
|
}
|
||||||
return item, createRequest(recipe)
|
return item, createRequest(recipe, i + 1)
|
||||||
end
|
end
|
||||||
while count > 0 do
|
while count > 0 do
|
||||||
ticker.requestFiltered(PRESS_ADDR, createRequest(recipe))
|
ticker.requestFiltered(PRESS_ADDR, createRequest(recipe))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue