fix: change the min fuel detection process during refuel

This commit is contained in:
Guillaume ARM 2024-05-11 13:20:39 +02:00
parent 1e6b431e1e
commit 3d9a1b9b94

View File

@ -17,8 +17,7 @@ local MAX_Z = TARGET_Z
local robot = robotApi.create()
local MAX_INVENTORY_BLOCKS = 16 * 64
local MIN_FUEL_NEEDED = FUEL_NEEDED_MULTIPLIER * ((config.size * 2) + INITIAL_TARGET_Y) + MAX_INVENTORY_BLOCKS + ADDITIONAL_FUEL_NEEDED
local MIN_PERCENTAGE_NEEDED = 10
local miner = {
robot = robot,
@ -64,10 +63,6 @@ local function checkConfig()
if isOdd(config.size) then
error('configured size should be even')
end
if MIN_FUEL_NEEDED > turtle.getFuelLimit() then
error('MIN_FUEL_NEEDED is higher than the turtle fuel limit')
end
end
local function prepareTurtle()
@ -104,7 +99,7 @@ local function refuelProcedure()
turtle.select(1)
while turtle.getFuelLevel() < MIN_FUEL_NEEDED do
while turtleUtils.getFuelPercentage() < MIN_PERCENTAGE_NEEDED do
turtleUtils.trySuckUp()
local ok = turtle.refuel()
@ -113,7 +108,8 @@ local function refuelProcedure()
end
end
print('> Refuel done.')
print('> Refuel done (' .. turtleUtils.getFuelPercentage() .. '%)')
miner.mission = 'return-mine'
end
@ -241,7 +237,7 @@ end
checkConfig()
prepareTurtle()
print("> Miner program started, minimum fuel needed: " .. MIN_FUEL_NEEDED)
print("> Miner program started, minimum percentgae fuel needed: " .. MIN_PERCENTAGE_NEEDED)
while not isProgramFinished() do
if miner.mission == 'unload' then