fix: change the min fuel detection process during refuel
This commit is contained in:
parent
1e6b431e1e
commit
3d9a1b9b94
14
miner.lua
14
miner.lua
@ -17,8 +17,7 @@ local MAX_Z = TARGET_Z
|
|||||||
|
|
||||||
local robot = robotApi.create()
|
local robot = robotApi.create()
|
||||||
|
|
||||||
local MAX_INVENTORY_BLOCKS = 16 * 64
|
local MIN_PERCENTAGE_NEEDED = 10
|
||||||
local MIN_FUEL_NEEDED = FUEL_NEEDED_MULTIPLIER * ((config.size * 2) + INITIAL_TARGET_Y) + MAX_INVENTORY_BLOCKS + ADDITIONAL_FUEL_NEEDED
|
|
||||||
|
|
||||||
local miner = {
|
local miner = {
|
||||||
robot = robot,
|
robot = robot,
|
||||||
@ -64,10 +63,6 @@ local function checkConfig()
|
|||||||
if isOdd(config.size) then
|
if isOdd(config.size) then
|
||||||
error('configured size should be even')
|
error('configured size should be even')
|
||||||
end
|
end
|
||||||
|
|
||||||
if MIN_FUEL_NEEDED > turtle.getFuelLimit() then
|
|
||||||
error('MIN_FUEL_NEEDED is higher than the turtle fuel limit')
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local function prepareTurtle()
|
local function prepareTurtle()
|
||||||
@ -104,7 +99,7 @@ local function refuelProcedure()
|
|||||||
|
|
||||||
turtle.select(1)
|
turtle.select(1)
|
||||||
|
|
||||||
while turtle.getFuelLevel() < MIN_FUEL_NEEDED do
|
while turtleUtils.getFuelPercentage() < MIN_PERCENTAGE_NEEDED do
|
||||||
turtleUtils.trySuckUp()
|
turtleUtils.trySuckUp()
|
||||||
|
|
||||||
local ok = turtle.refuel()
|
local ok = turtle.refuel()
|
||||||
@ -113,7 +108,8 @@ local function refuelProcedure()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
print('> Refuel done.')
|
print('> Refuel done (' .. turtleUtils.getFuelPercentage() .. '%)')
|
||||||
|
|
||||||
miner.mission = 'return-mine'
|
miner.mission = 'return-mine'
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -241,7 +237,7 @@ end
|
|||||||
checkConfig()
|
checkConfig()
|
||||||
prepareTurtle()
|
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
|
while not isProgramFinished() do
|
||||||
if miner.mission == 'unload' then
|
if miner.mission == 'unload' then
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user