Compare commits
No commits in common. "9fe8b3f78c4228a235bf18702d46b1b520a4ac85" and "eeff05593f04157923011e5decf22847080aca0f" have entirely different histories.
9fe8b3f78c
...
eeff05593f
1 changed files with 12 additions and 23 deletions
|
|
@ -57,6 +57,7 @@ local order = {
|
||||||
end,
|
end,
|
||||||
biofuel = function (amt, ticker)
|
biofuel = function (amt, ticker)
|
||||||
-- TODO
|
-- TODO
|
||||||
|
amt = math.floor(amt / 125)
|
||||||
local request = function ()
|
local request = function ()
|
||||||
local biomass = {
|
local biomass = {
|
||||||
name = "createaddition:biomass",
|
name = "createaddition:biomass",
|
||||||
|
|
@ -72,32 +73,20 @@ local order = {
|
||||||
}
|
}
|
||||||
return biomass, sugar, cinder_flour
|
return biomass, sugar, cinder_flour
|
||||||
end
|
end
|
||||||
local enoughMaterials = function ()
|
local notEnoughMaterials = function ()
|
||||||
|
-- TODO
|
||||||
-- use ticker to test ( biomass >= 32, sugar >= 16, and cinder flour >= 16
|
-- use ticker to test ( biomass >= 32, sugar >= 16, and cinder flour >= 16
|
||||||
local check = {}
|
|
||||||
check["createaddition:biomass"] = 32
|
|
||||||
check["minecraft:sugar"] = 16
|
|
||||||
check["create:cinder_flour"] = 16
|
|
||||||
for _, item in pairs(ticker.stock()) do
|
|
||||||
if check[item.name] then
|
|
||||||
check[item.name] = check[item.name] - item.count
|
|
||||||
end
|
end
|
||||||
|
local make_order = function (amt_to_make, amt_made)
|
||||||
|
if amt_to_make <= 0 then return amt_made end
|
||||||
|
if notEnoughMaterials() then return amt_made end
|
||||||
|
local count = ticker.requestFiltered(BIOFUEL_PKG, request())
|
||||||
|
if count == 0 then return amt_made end
|
||||||
|
amt_to_make = amt_to_make - count
|
||||||
|
amt_made = amt_made + count
|
||||||
|
return make_order (amt_to_make, amt_made)
|
||||||
end
|
end
|
||||||
local enough_materials = true
|
return make_order (amt, 0)
|
||||||
for name, count in pairs(check) do
|
|
||||||
if count > 0 then enough_materials = false end
|
|
||||||
end
|
|
||||||
return enough_materials
|
|
||||||
end
|
|
||||||
|
|
||||||
local amt_made = 0
|
|
||||||
while amt_made < amt do
|
|
||||||
if not enoughMaterials() then break end
|
|
||||||
ticker.requestFiltered(BIOFUEL_PKG, request())
|
|
||||||
amt_made = amt_made + 2000
|
|
||||||
os.sleep(1)
|
|
||||||
end
|
|
||||||
return amt_made
|
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue