fix(coal-crafter): waitForNotEnoughCoal

This commit is contained in:
Guillaume ARM 2024-05-20 02:14:38 +02:00
parent 694a23fb68
commit cd0e42e34c

View File

@ -8,15 +8,25 @@ local MIN_ESSENCE_NEEDED = 8
local COAL_ESSENCE_NAME = 'mysticalagriculture:coal_essence'
local COAL_NAME = 'minecraft:coal'
local function countCoalItems(inventory)
local total = 0
for slot, item in pairs(inventory.list()) do
if item.name == COAL_NAME then
total = total + item.count
end
end
return total
end
local function waitForNotEnoughCoal(inventory)
while true do
for slot, item in pairs(inventory.list()) do
local enoughCoal = item.name == COAL_NAME and item.count >= NB_NEEDED_COAL
local nbCoals = countCoalItems(inventory)
if not enoughCoal then
if nbCoals < NB_NEEDED_COAL then
return
end
end
os.sleep(IDLE_TIME_ENOUGH_COAL)
end