fix(coal-crafter): waitForNotEnoughCoal
This commit is contained in:
parent
694a23fb68
commit
cd0e42e34c
@ -8,14 +8,24 @@ local MIN_ESSENCE_NEEDED = 8
|
|||||||
local COAL_ESSENCE_NAME = 'mysticalagriculture:coal_essence'
|
local COAL_ESSENCE_NAME = 'mysticalagriculture:coal_essence'
|
||||||
local COAL_NAME = 'minecraft:coal'
|
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)
|
local function waitForNotEnoughCoal(inventory)
|
||||||
while true do
|
while true do
|
||||||
for slot, item in pairs(inventory.list()) do
|
local nbCoals = countCoalItems(inventory)
|
||||||
local enoughCoal = item.name == COAL_NAME and item.count >= NB_NEEDED_COAL
|
|
||||||
|
|
||||||
if not enoughCoal then
|
if nbCoals < NB_NEEDED_COAL then
|
||||||
return
|
return
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
os.sleep(IDLE_TIME_ENOUGH_COAL)
|
os.sleep(IDLE_TIME_ENOUGH_COAL)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user