Castaras

Base Tunnel Program

May 25th, 2013
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.42 KB | None | 0 0
  1. local tArgs = { ... }
  2. if #tArgs ~= 1 then
  3.         print( "tunnel <length>, where length is the number of 6x5 sections you require." )
  4.         return
  5. end
  6.  
  7. function clear()
  8. while turtle.detect() do
  9. turtle.dig()
  10. sleep(0.8)
  11. end
  12. end
  13.  
  14. function clearForward()
  15. while turtle.detect() do
  16. turtle.dig()
  17. sleep(0.8)
  18. end
  19. while not turtle.forward() do
  20. turtle.attack()
  21. end
  22. end
  23.  
  24. function clearUp()
  25. while turtle.detectUp() do
  26. turtle.digUp()
  27. sleep(0.8)
  28. end
  29. while not turtle.up() do
  30. turtle.attack()
  31. end
  32. end
  33.  
  34. function clearDown()
  35. if turtle.detectDown() then turtle.digDown() end
  36. end
  37.  
  38.  
  39. turtle.select(1)
  40. turtle.refuel(1)
  41.  
  42. for k=1,tArgs[1] do
  43.  
  44. -- Level 0 & 1
  45. turtle.turnLeft()
  46. turtle.forward()
  47. turtle.turnRight()
  48. turtle.select(2)
  49. for i=1,6 do
  50. clear()
  51. turtle.forward()
  52. turtle.digDown()
  53. turtle.placeDown()
  54. turtle.turnLeft()
  55. clear()
  56. turtle.select(3)
  57. turtle.place()
  58. turtle.select(2)
  59. turtle.turnRight()
  60. end
  61.  
  62. turtle.turnRight()
  63. clear()
  64. turtle.forward()
  65. turtle.turnRight()
  66. turtle.digDown()
  67. turtle.placeDown()
  68.  
  69. for i=1,5 do
  70. clear()
  71. turtle.forward()
  72. turtle.digDown()
  73. turtle.placeDown()
  74. end
  75.  
  76. turtle.turnLeft()
  77. clear()
  78. turtle.forward()
  79. turtle.select(3)
  80. clear()
  81. turtle.place()
  82. turtle.select(2)
  83. turtle.digDown()
  84. turtle.placeDown()
  85. turtle.turnLeft()
  86.  
  87. for i=1,5 do
  88. clear()
  89. turtle.forward()
  90. turtle.digDown()
  91. turtle.placeDown()
  92. turtle.turnRight()
  93. clear()
  94. turtle.select(3)
  95. turtle.place()
  96. turtle.select(2)
  97. turtle.turnLeft()
  98. end
  99.  
  100. -- Level 2
  101. clearUp()
  102. turtle.select(3)
  103. turtle.turnRight()
  104. clear()
  105. turtle.place()
  106. turtle.turnRight()
  107. turtle.select(4)
  108. for i=1,5 do
  109. clear()
  110. turtle.forward()
  111. turtle.turnLeft()
  112. clear()
  113. turtle.place()
  114. turtle.turnRight()
  115. end
  116. turtle.turnRight()
  117. clear()
  118. turtle.forward()
  119. clear()
  120. turtle.forward()
  121. clear()
  122. turtle.place()
  123. turtle.turnRight()
  124. for i=1,4 do
  125. clear()
  126. turtle.forward()
  127. turtle.turnLeft()
  128. clear()
  129. turtle.place()
  130. turtle.turnRight()
  131. end
  132.  
  133. turtle.select(3)
  134. clear()
  135. turtle.forward()
  136. turtle.turnLeft()
  137. clear()
  138. turtle.place()
  139. turtle.turnRight()
  140.  
  141. -- Level 3
  142.  
  143. clearUp()
  144. turtle.turnLeft()
  145. clear()
  146. turtle.place()
  147. turtle.turnLeft()
  148.  
  149. for i=1,5 do
  150. clear()
  151. turtle.forward()
  152. turtle.turnRight()
  153. clear()
  154. turtle.place()
  155. turtle.turnLeft()
  156. end
  157.  
  158. turtle.turnLeft()
  159. clear()
  160. turtle.forward()
  161. clear()
  162. turtle.forward()
  163. clear()
  164. turtle.place()
  165. turtle.turnLeft()
  166.  
  167. for i=1,5 do
  168. clear()
  169. turtle.forward()
  170. turtle.turnRight()
  171. clear()
  172. turtle.place()
  173. turtle.turnLeft()
  174. end
  175.  
  176. turtle.back()
  177. turtle.place()
  178. turtle.turnLeft()
  179. clear()
  180. turtle.forward()
  181. turtle.turnRight()
  182. clear()
  183. turtle.place()
  184. turtle.turnLeft()
  185. clear()
  186. turtle.forward()
  187. turtle.turnRight()
  188. clear()
  189. turtle.place()
  190.  
  191. --level 4
  192. clearUp()
  193. clear()
  194. turtle.place()
  195. turtle.turnRight()
  196. clear()
  197. turtle.forward()
  198. turtle.turnLeft()
  199. clear()
  200. turtle.place()
  201. turtle.turnRight()
  202. clear()
  203. turtle.forward()
  204. turtle.turnLeft()
  205. clear()
  206. turtle.place()
  207. turtle.turnLeft()
  208. turtle.forward()
  209. turtle.turnLeft()
  210. for i=1,4 do
  211. clear()
  212. turtle.forward()
  213. end
  214.  
  215. turtle.select(4)
  216.  
  217. for i=1,5 do
  218. turtle.turnLeft()
  219. clear()
  220. turtle.place()
  221. turtle.turnRight()
  222. turtle.turnRight()
  223. clear()
  224. turtle.place()
  225. turtle.turnLeft()
  226. turtle.back()
  227. end
  228.  
  229. -- Cleanup
  230.  
  231. clearDown()
  232. turtle.down()
  233. clearDown()
  234. turtle.placeUp()
  235. for i=1,4 do
  236. clear()
  237. turtle.forward()
  238. turtle.placeUp()
  239. clearDown()
  240. end
  241. turtle.down()
  242. turtle.down()
  243. turtle.turnRight()
  244. turtle.turnRight()
  245. for i=1,5 do
  246. turtle.forward()
  247. end
  248.  
  249.  
  250. end --overall loop
Advertisement
Add Comment
Please, Sign In to add comment