c9e8e1b9dd2870c0---- --[[Computer slot 1, Filter slot 2, Timer slot 3, Chest slot 4, Fuel slot 15, torches slot 16.]] -- Create the function for refueling function checkFuel() if turtle.getFuelLevel() <= 20 then if turtle.getItemCount(15) == 0 then print("Out of fuel.") exit() else turtle.select(15) turtle.refuel(1) turtle.select(1) end --if end --if end --checkFuel() -- Create the turnAround function function turnAround() turtle.turnRight() turtle.turnRight() end --turnAround() -- Digs the tunnel for the given length function tunnel(givenLength) local torchDistance = 0 d = 0 while d <= 75 do if turtle.detect() then repeat turtle.dig() sleep(0.50) until turtle.detect() == false end --if turtle.forward() if turtle.detectUp() then repeat turtle.digUp() sleep(0.50) until turtle.detectUp() == false end --if turtle.turnLeft() if turtle.detect() then repeat turtle.dig() sleep(0.50) until turtle.detect() == false end --if turtle.up() if turtle.detect() then repeat turtle.dig() sleep(0.50) until turtle.detect() == false end--if turtle.turnRight() turtle.turnRight() if turtle.detect() then repeat turtle.dig() sleep(0.50) until turtle.detect() == false end turtle.down() if turtle.detect() then repeat turtle.dig() sleep(0.50) until turtle.detect() == false end turtle.turnLeft() d = d + 1 torchDistance = torchDistance + 1 -- attempts to place a block below turtle.select(1) turtle.placeDown() -- Places a torch every 9 blocks if torchDistance == 9 then print("Placing torch...") turtle.select(16) turnAround() turtle.place() turnAround() torchDistance = 0 checkFuel() end --if end --for -- Sends the turtle back to the start turtle.up() turnAround() for index = 1,givenLength do checkFuel() if not turtle.detect() then turtle.forward() else repeat turtle.dig() turtle.sleep(0.25) until turtle.detect() == false turtle.forward() end --if end --for turtle.down() turnAround() end --tunnel() -- Main script print("Input tunnel length:") local length = 75 print("Starting excavation...") tunnel(length) term.clear() print("The tunnel has been excavated!")