fix(tunnels-miner): try to avoid torches + do not check for empty inventory each loop

This commit is contained in:
Guillaume ARM 2024-05-26 04:10:23 +02:00
parent 12a50ebf6a
commit 32783f7ebc

View File

@ -6,7 +6,7 @@ local TIME_TO_START = 3
local IDLE_TIME_BETWEEN_TUNNELS = 1
local SPACE_BETWEEN_TUNNELS = 3
local VERSION = "1.0.3"
local VERSION = "1.1.0"
local MOVES_BY_DIRECTION = {
right = {
@ -59,17 +59,17 @@ local function assertValidConfig(config)
end
end
local function printFuelReport(config)
print('> current fuel: ' .. turtleUtils.getFuelPercentage() .. '%')
print('> fuel needed: ' .. turtleUtils.getFuelPercentage(getMinFuelNeeded(config)) .. '%')
end
local function assertInventoryIsEmpty()
if not turtleUtils.isInventoryEmpty() then
error('turtle inventory should be empty', 0)
end
end
local function printFuelReport(config)
print('> current fuel: ' .. turtleUtils.getFuelPercentage() .. '%')
print('> fuel needed: ' .. turtleUtils.getFuelPercentage(getMinFuelNeeded(config)) .. '%')
end
local function findGroundProcedure()
local foundGround, errMessage = turtleUtils.goGround()
if not foundGround then
@ -117,19 +117,22 @@ local function dropAllProcedure(config)
end
getMoves(config).turnLeft()
turtleUtils.forceUp()
-- turtleUtils.forceUp()
end
local function goToNextMineProcedure(config)
getMoves(config).turnLeft()
digForward(SPACE_BETWEEN_TUNNELS)
getMoves(config).turnLeft()
turtleUtils.forceUp()
end
local function main(config)
assertValidConfig(config)
turtleUtils.refuelAllFromInventory()
assertInventoryIsEmpty() -- Warning here when implementing persistance
printFuelReport(config)
assertEnoughFuelForTunnel(config)
@ -146,7 +149,6 @@ local function main(config)
printFuelReport(config)
assertEnoughFuelForTunnel(config)
end
assertInventoryIsEmpty() -- Warning here when implementing persistance
print('> Start mining tunnel number ' .. tostring(tunnelNumber))