adamg765

Tunnel

Jan 12th, 2017
100
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local length = 200
  2.  
  3. local function refuel()
  4. if turtle.getFuelLevel() < 50 then
  5. local prev = turtle.getSelectedSlot()
  6. turtle.select(1)
  7. if not turtle.refuel(4) then
  8. print('Need more fuel')
  9. while not turtle.refuel(4) do
  10. sleep(1)
  11. end
  12. end
  13. turtle.select(prev)
  14. end
  15. end
  16.  
  17. local function tryForwards()
  18. refuel()
  19. while not turtle.forward() do
  20. if turtle.detect() then
  21. turtle.dig()
  22. sleep(.5)
  23. while turtle.detect() do
  24. turtle.dig()
  25. sleep(.5)
  26. end
  27. elseif turtle.attack() then
  28. else
  29. sleep(1)
  30. end
  31. end
  32. end
  33.  
  34. local function tryUp()
  35. refuel()
  36. while not turtle.up() do
  37. if turtle.detectUp() then
  38. turtle.digUp()
  39. sleep(.5)
  40. while turtle.detectUp() do
  41. turtle.digUp()
  42. sleep(.5)
  43. end
  44. elseif turtle.attackUp() then
  45. else
  46. sleep(1)
  47. end
  48. end
  49. end
  50.  
  51. local function tryDown()
  52. refuel()
  53. while not turtle.down() do
  54. if turtle.detectDown() then
  55. turtle.digDown()
  56. elseif turtle.attackDown() then
  57. else
  58. sleep(1)
  59. end
  60. end
  61. end
  62.  
  63. local function turnAround()
  64. turtle.turnLeft()
  65. turtle.turnLeft()
  66. end
  67.  
  68. local function level()
  69. tryForwards()
  70. turtle.turnLeft()
  71.  
  72. tryForwards()
  73. tryUp()
  74. turtle.digUp()
  75.  
  76. tryForwards()
  77. tryUp()
  78.  
  79. tryForwards()
  80. tryUp()
  81.  
  82. turnAround()
  83. turtle.digUp()
  84. tryForwards()
  85. turtle.dig()
  86. tryUp()
  87.  
  88. turtle.dig()
  89. tryUp()
  90. tryForwards()
  91.  
  92. tryUp()
  93. tryForwards()
  94. turtle.dig()
  95. tryDown()
  96. turtle.digDown()
  97. tryForwards()
  98. turtle.dig()
  99. tryDown()
  100. tryForwards()
  101. turtle.dig()
  102. tryDown()
  103. turtle.dig()
  104. turnAround()
  105. tryForwards()
  106. turtle.dig()
  107. tryDown()
  108. turtle.dig()
  109. turnAround()
  110. tryForwards()
  111. turtle.dig()
  112. tryDown()
  113. turnAround()
  114. tryForwards()
  115. turtle.dig()
  116. tryDown()
  117. tryForwards()
  118. turtle.turnRight()
  119.  
  120.  
  121. end
  122.  
  123. for i=1, length, 1 do
  124. level()
  125. end
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×