Advertisement
25hz

Turtle - Dig 3 x 3 Tunnel

Oct 15th, 2013
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.34 KB | None | 0 0
  1. -- This will dig a 3 x 3 tunnel, place torches and
  2. -- return. Place the turtle one block up
  3. -- from the floor.
  4. -- Usage: 3tunnel 5
  5. -- It will mine a 3 x 3 tunnel, 5 blocks long.
  6.  
  7. -- Original code by SeleckPlays.
  8. -- https://www.youtube.com/watch?v=ftiOe6ztQg4
  9. --  Slightly modded by 25hz
  10.  
  11. function digIt()
  12.   while turtle.detect() do
  13.     turtle.dig()
  14.     os.sleep(1.0)
  15.   end
  16.   turtle.forward()
  17.   while turtle.detectDown() or turtle.detectUp() do
  18.     turtle.digUp()
  19.     turtle.digDown()
  20.   end
  21. end
  22.  
  23. function placeTorch()
  24.   turtle.back()
  25.   turtle.turnLeft()
  26.   turtle.forward()
  27.   turtle.select(13)
  28.   turtle.placeUp()
  29.   turtle.back()
  30.   turtle.turnRight()
  31.   turtle.forward()
  32. end
  33.  
  34. local run = 0
  35. local j = 0
  36. local k = 0
  37.  
  38. term.write("Tunnel length?  ")
  39. run = read()
  40.  
  41. -- This places the torches.  Change
  42. -- the number after the % sign to
  43. -- change how far apart the torches are.
  44. for i = 1, run do
  45.   k = i - 1
  46.   j = k % 5
  47.  
  48.   if j == 1 then
  49.     placeTorch()
  50.   end
  51.  
  52.   digIt()
  53.   turtle.turnLeft()
  54.   digIt()
  55.   turtle.turnRight()
  56.   turtle.turnRight()
  57.   turtle.forward()
  58.   digIt()
  59.   turtle.turnLeft()
  60.   turtle.turnLeft()
  61.   turtle.forward()
  62.   turtle.turnRight()
  63. end
  64.  
  65. -- This makes the turtle return to start
  66. -- at ground level.
  67. turtle.down()
  68. turtle.turnRight()
  69. turtle.turnRight()
  70. for i = 1, run do
  71.   turtle.forward()
  72. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement