Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. -- get arguments
  2.  
  3. local tArgs = { ... }
  4. if #tArgs ~= 1 then
  5. print( "Usage: basicTunnel; <Tunnel Length divided by 2>" )
  6. return
  7. end
  8.  
  9. local tunnelLength = tonumber( tArgs[1] )
  10. if tunnelLength < 1 then
  11. print( "Tunnel Length must be positive!" )
  12. return
  13. end
  14.  
  15. -- function to tunnel 1x3 directly in front moving into new space
  16.  
  17. local function digInFront ()
  18.  
  19. if turtle.detect() then
  20. if turtle.dig() then
  21. turtle.suckDown()
  22. end
  23. end
  24.  
  25. turtle.forward()
  26.  
  27. if turtle.detectUp() then
  28. if turtle.digUp() then
  29. turtle.suckDown()
  30. end
  31. end
  32.  
  33. if turtle.detectDown() then
  34. if turtle.digDown() then
  35. turtle.suckDown()
  36. end
  37. end
  38.  
  39. turtle.back()
  40. end
  41.  
  42. -- program start
  43.  
  44. local done = false
  45.  
  46. while not done do
  47. for n = 0, tunnelLength do
  48.  
  49. digInFront()
  50. turtle.turnRight()
  51. digInFront()
  52. digInFront()
  53. turtle.turnLeft()
  54.  
  55. digInFront()
  56. turtle.turnLeft()
  57. digInFront()
  58. digInFront()
  59. turtle.turnRight()
  60. end
  61. done = true
  62. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement