fix: better handling of the minimum fuel limit

This commit is contained in:
Guillaume ARM 2024-05-09 03:05:54 +02:00
parent 4c84f48207
commit 09d15d0db7

View File

@ -4,6 +4,7 @@ local config = require('config-miner')
local LOWER_SIZE_LIMIT = 2;
local HIGHER_SIZE_LIMIT = 128;
local FUEL_NEEDED_MULTIPLIER = 3
local ADDITIONAL_FUEL_NEEDED = 256
local INITIAL_TARGET_Y = config.targetY - config.startY
@ -17,7 +18,7 @@ local MAX_Z = TARGET_Z
local robot = robotApi.create()
local MAX_INVENTORY_BLOCKS = 16 * 64
local MIN_FUEL_NEEDED = 2 * ((config.size * 2) + INITIAL_TARGET_Y) + MAX_INVENTORY_BLOCKS + ADDITIONAL_FUEL_NEEDED
local MIN_FUEL_NEEDED = FUEL_NEEDED_MULTIPLIER * ((config.size * 2) + INITIAL_TARGET_Y) + MAX_INVENTORY_BLOCKS + ADDITIONAL_FUEL_NEEDED
local miner = {
robot = robot,
@ -63,6 +64,10 @@ 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()