-- Save the initial position of the turtle local initialX, initialY, initialZ = gps.locate() -- Dig a 2 block tall, 1 block wide tunnel of user-inputted length function digTunnel(length) for i = 1, length do turtle.digUp() turtle.dig() turtle.forward() turtle.digUp() turtle.dig() -- Place a torch every 11 blocks if i % 11 == 0 then turtle.select(1) -- Assuming torches are in the first slot turtle.turnRight() turtle.dig() turtle.place() turtle.turnLeft() end end end -- Return to the initial location and drop all items function returnAndDropItems(length) -- Turn around 180 degrees turtle.turnRight() turtle.turnRight() for i = 1, length do turtle.forward() end -- Drop all items for slot = 2, 16 do turtle.select(slot) turtle.drop() end end -- Main program print("Enter the desired tunnel length:") local length = tonumber(read()) -- Dig the tunnel digTunnel(length) -- Return to initial location and drop items returnAndDropItems(length)