feat: implements enoughMaterials function
purpose: check for materials to craft 2b of biofuel
This commit is contained in:
parent
eeff05593f
commit
c3e20db2c5
1 changed files with 16 additions and 3 deletions
|
|
@ -73,13 +73,26 @@ local order = {
|
|||
}
|
||||
return biomass, sugar, cinder_flour
|
||||
end
|
||||
local notEnoughMaterials = function ()
|
||||
-- TODO
|
||||
local enoughMaterials = function ()
|
||||
-- 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 enough_materials = true
|
||||
for name, count in pairs(check) do
|
||||
if count > 0 then enough_materials = false end
|
||||
end
|
||||
return enough_materials
|
||||
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
|
||||
if not enoughMaterials() 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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue