fix(coal-crafter): waitForNotEnoughCoal
This commit is contained in:
parent
694a23fb68
commit
cd0e42e34c
@ -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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user