rabidfungi

Dig Tunnel

Jul 18th, 2025
408
0
Never
4
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.20 KB | Gaming | 0 0
  1. --Dig Tunnel
  2.  
  3. function digIt()
  4.     while turtle.detect() do
  5.       turtle.dig()
  6.       os.sleep(0.5)
  7.     end
  8.     turtle.forward()
  9.     while turtle.detectDown() or turtle.detectUp() do
  10.       turtle.digUp()
  11.       turtle.digDown()
  12.     end
  13.   end
  14.  
  15.   function placeTorch()
  16.     turtle.select(16)
  17.     turtle.placeFront()
  18.   end
  19.  
  20.   local run = 0
  21.   term.write("Tunnel length: ")
  22.   run = read()
  23.  
  24.   for x = 1, run do
  25.     y = x - 1
  26.     z = y % 4
  27.     digIt()
  28.     turtle.turnLeft()
  29.     digIt()
  30.     turtle.turnRight()
  31.     turtle.turnRight()
  32.     turtle.forward()
  33.     digIt()
  34.     turtle.back()
  35.     turtle.turnLeft()
  36.  
  37.     if x == 2 or z == 1 then
  38.       turtle.back()
  39.       turtle.turnRight()
  40.       turtle.forward()
  41.       placeTorch()
  42.       turtle.back()
  43.       turtle.back()
  44.       turtle.turnRight()
  45.       turtle.turnRight()
  46.       placeTorch()
  47.       turtle.turnRight()
  48.       turtle.turnRight()
  49.       turtle.forward()
  50.       turtle.turnLeft()
  51.       turtle.forward()
  52.     end
  53.    -- Place final torch mid wall
  54.    turtle.down()
  55.    turtle.turnRight()
  56.    turtle.turnRight()
  57.    turtle.select(16)
  58.    turtle.placeUp()
  59.  
  60.    --Return to start
  61.    for x = 1, run do
  62.      turtle.forward()
  63.    end
Advertisement
Comments
  • User was banned
  • User was banned
  • User was banned
  • User was banned
Add Comment
Please, Sign In to add comment