From 3d9a1b9b94f09d1c90d73d8a68405933f4cbd36d Mon Sep 17 00:00:00 2001 From: Guillaume ARM Date: Sat, 11 May 2024 13:20:39 +0200 Subject: [PATCH] fix: change the min fuel detection process during refuel --- miner.lua | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/miner.lua b/miner.lua index 4b62113..dc1074a 100644 --- a/miner.lua +++ b/miner.lua @@ -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