From 32783f7ebc6c8490ffe32dce1f763234e046ead2 Mon Sep 17 00:00:00 2001 From: Guillaume ARM Date: Sun, 26 May 2024 04:10:23 +0200 Subject: [PATCH] fix(tunnels-miner): try to avoid torches + do not check for empty inventory each loop --- tunnels-miner.lua | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/tunnels-miner.lua b/tunnels-miner.lua index 70a0483..67a16b3 100644 --- a/tunnels-miner.lua +++ b/tunnels-miner.lua @@ -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))