distance = 0 rounds = 0 tunnel = 0 args = {...} if #args < 1 then print("Usage: branchmine [spacing] [length]") return end tunnels = tonumber(args[1]) if #args > 1 then spacing = tonumber(args[2]) if #args > 2 then length = tonumber(args[3]) else length = 15 end else spacing = 2 length = 15 end print("Preparing to dig "..tunnels.." tunnels with a spacing of "..spacing.." and a length of "..length..".") spacing = spacing + 1 local function checkFuel() if turtle.getFuelLevel() < 10 then print("I seem to be low on fuel. Refueling...") turtle.select(1) turtle.refuel(1) end end local function safeForward() while not turtle.forward() do turtle.dig() end end local function clearInv() print("Clearing inventory...") turtle.up() turtle.digUp() turtle.up() turtle.digUp() turtle.down() turtle.select(3) turtle.placeUp() for i = 5, 16 do turtle.select(i) turtle.dropUp() end turtle.select(1) turtle.down() checkFuel() end local function torch() if turtle.getItemCount(4) == 0 then print("Warning: Out of torches") return end turtle.select(4) turtle.placeUp() end local function doFloor() if not turtle.detectDown() then turtle.select(2) turtle.placeDown() end end local function tunnelForward() while distance < spacing do checkFuel() turtle.digUp() doFloor() turtle.dig() safeForward() distance = distance + 1 end distance = 0 end local function backtomain() turtle.turnLeft() turtle.turnLeft() while tunnel > 0 do checkFuel() if tunnel % 7 == 4 then torch() end safeForward() tunnel = tunnel - 1 end end local function doTunnel() while tunnel < length do checkFuel() turtle.digUp() doFloor() turtle.dig() safeForward() tunnel = tunnel + 1 end turtle.digUp() end while rounds < tunnels do tunnelForward() turtle.digUp() turtle.turnLeft() doTunnel() backtomain() doTunnel() backtomain() turtle.turnRight() if turtle.getItemCount(15) > 0 then clearInv() end rounds = rounds + 1 print("Round #" .. rounds .. " done!") end print("All done :3")