fix(tunnels-miner): try to avoid torches + do not check for empty inventory each loop
This commit is contained in:
parent
12a50ebf6a
commit
32783f7ebc
@ -6,7 +6,7 @@ local TIME_TO_START = 3
|
|||||||
local IDLE_TIME_BETWEEN_TUNNELS = 1
|
local IDLE_TIME_BETWEEN_TUNNELS = 1
|
||||||
local SPACE_BETWEEN_TUNNELS = 3
|
local SPACE_BETWEEN_TUNNELS = 3
|
||||||
|
|
||||||
local VERSION = "1.0.3"
|
local VERSION = "1.1.0"
|
||||||
|
|
||||||
local MOVES_BY_DIRECTION = {
|
local MOVES_BY_DIRECTION = {
|
||||||
right = {
|
right = {
|
||||||
@ -59,17 +59,17 @@ local function assertValidConfig(config)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function printFuelReport(config)
|
|
||||||
print('> current fuel: ' .. turtleUtils.getFuelPercentage() .. '%')
|
|
||||||
print('> fuel needed: ' .. turtleUtils.getFuelPercentage(getMinFuelNeeded(config)) .. '%')
|
|
||||||
end
|
|
||||||
|
|
||||||
local function assertInventoryIsEmpty()
|
local function assertInventoryIsEmpty()
|
||||||
if not turtleUtils.isInventoryEmpty() then
|
if not turtleUtils.isInventoryEmpty() then
|
||||||
error('turtle inventory should be empty', 0)
|
error('turtle inventory should be empty', 0)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function printFuelReport(config)
|
||||||
|
print('> current fuel: ' .. turtleUtils.getFuelPercentage() .. '%')
|
||||||
|
print('> fuel needed: ' .. turtleUtils.getFuelPercentage(getMinFuelNeeded(config)) .. '%')
|
||||||
|
end
|
||||||
|
|
||||||
local function findGroundProcedure()
|
local function findGroundProcedure()
|
||||||
local foundGround, errMessage = turtleUtils.goGround()
|
local foundGround, errMessage = turtleUtils.goGround()
|
||||||
if not foundGround then
|
if not foundGround then
|
||||||
@ -117,19 +117,22 @@ local function dropAllProcedure(config)
|
|||||||
end
|
end
|
||||||
|
|
||||||
getMoves(config).turnLeft()
|
getMoves(config).turnLeft()
|
||||||
turtleUtils.forceUp()
|
-- turtleUtils.forceUp()
|
||||||
end
|
end
|
||||||
|
|
||||||
local function goToNextMineProcedure(config)
|
local function goToNextMineProcedure(config)
|
||||||
getMoves(config).turnLeft()
|
getMoves(config).turnLeft()
|
||||||
digForward(SPACE_BETWEEN_TUNNELS)
|
digForward(SPACE_BETWEEN_TUNNELS)
|
||||||
getMoves(config).turnLeft()
|
getMoves(config).turnLeft()
|
||||||
|
turtleUtils.forceUp()
|
||||||
end
|
end
|
||||||
|
|
||||||
local function main(config)
|
local function main(config)
|
||||||
assertValidConfig(config)
|
assertValidConfig(config)
|
||||||
|
|
||||||
turtleUtils.refuelAllFromInventory()
|
turtleUtils.refuelAllFromInventory()
|
||||||
|
assertInventoryIsEmpty() -- Warning here when implementing persistance
|
||||||
|
|
||||||
printFuelReport(config)
|
printFuelReport(config)
|
||||||
assertEnoughFuelForTunnel(config)
|
assertEnoughFuelForTunnel(config)
|
||||||
|
|
||||||
@ -146,7 +149,6 @@ local function main(config)
|
|||||||
printFuelReport(config)
|
printFuelReport(config)
|
||||||
assertEnoughFuelForTunnel(config)
|
assertEnoughFuelForTunnel(config)
|
||||||
end
|
end
|
||||||
assertInventoryIsEmpty() -- Warning here when implementing persistance
|
|
||||||
|
|
||||||
print('> Start mining tunnel number ' .. tostring(tunnelNumber))
|
print('> Start mining tunnel number ' .. tostring(tunnelNumber))
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user