Advertisement
Guest User

Untitled

a guest
Jul 8th, 2015
261
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.58 KB | None | 0 0
  1. --variables
  2. local currentHeight
  3. local endHeight
  4. local currentNS
  5. local endNS
  6. local currentWE
  7. local endWE
  8. local tempHeight
  9. local tempNS
  10. local tempWE
  11. local currentDirection = 'n'
  12. local endDirection
  13. local ladderSelection = 'n'
  14. local tunnelSelection = 'n'
  15. local ladderTorch = 0
  16. local tunnelTorch = 0
  17.  
  18.  
  19.  
  20. --functions
  21. function return()
  22. tempHeight = currentHeight
  23. currentHeight = endHeight
  24. endHeight = tempHeight
  25. tempNS =endNS
  26. currentNS = endNS
  27. endNS = tempNS
  28. tempWE = currentWE
  29. currentWE = endWE
  30. endWE = tempWE
  31.  
  32. function tunnels()
  33. turtle.digUp()
  34. turtle.digDown()
  35. turtle.turnLeft()
  36. turtle.dig()
  37. turtle.forward()
  38. turtle.digUp()
  39. turtle.dig()
  40. tunnelTorch = tunnelTorch +1
  41. local placeTorch = tunnelTorch%10
  42. if placeTorch ==1 then
  43. turtle.select(2)
  44. turtle.place()
  45. end
  46. turtle.digDown()
  47. turtle.back()
  48. turtle.turnRight()
  49. turtle.turnRight()
  50. turtle.dig()
  51. turtle.forward()
  52. turtle.digUp()
  53. turtle.dig()
  54. turtle.digDown()
  55. turtle.back()
  56. turtle.turnLeft()
  57. end
  58.  
  59.  
  60. function ladders()
  61. local blockFront = turtle.detect()
  62. if blockFront == true then
  63. turtle.select(1)
  64. turtle.dig()
  65. turtle.place()
  66. ladderTorch = ladderTorch +1
  67. local placeTorch = ladderTorch%5
  68. if placeTorch ==1 then
  69. turtle.turnLeft()
  70. turtle.dig()
  71. turtle.select(2)
  72. turtle.place()
  73. turtle.turnRight()
  74. end
  75. end
  76. end
  77. function turnRight(c,e)
  78. turtle.turnRight()
  79. currentDirection = e
  80. end
  81.  
  82. function turnAround(c,e)
  83. turtle.turnRight() turtle.turnRight()
  84. currentDirection = e
  85. end
  86.  
  87. function turnLeft(c,e)
  88. turtle.turnLeft()
  89. currentDirection = e
  90. end
  91.  
  92. function compus()
  93. if (currentDirection == 'n') and (endDirection =='e') then
  94. turnRight('n','e') end
  95. if (currentDirection == 'n') and (endDirection =='s') then
  96. turnAround('n','s') end
  97. if (currentDirection == 'n') and (endDirection =='w') then
  98. turnLeft('n','w') end
  99. if (currentDirection == 'e') and (endDirection =='s') then
  100. turnRight('e','s') end
  101. if (currentDirection == 'e') and (endDirection =='w') then
  102. turnAround('e','w') end
  103. if (currentDirection == 'e') and (endDirection =='n') then
  104. turnLeft('e','n') end
  105. if (currentDirection == 's') and (endDirection =='w') then
  106. turnRight('s','w') end
  107. if (currentDirection == 's') and (endDirection =='n') then
  108. turnAround('s','n') end
  109. if (currentDirection == 's') and (endDirection =='e') then
  110. turnLeft('s','e') end
  111. if (currentDirection == 'w') and (endDirection =='n') then
  112. turnRight('w','n') end
  113. if (currentDirection == 'w') and (endDirection =='e') then
  114. turnAround('w','e') end
  115. if (currentDirection == 'w') and (endDirection =='s') then
  116. turnLeft('w','s') end
  117. end
  118.  
  119. function moveHeight()
  120. if currentHeight<endHeight then
  121. local blockUp = turtle.detectUp()
  122. if ladderSelection == 'y' then
  123. ladders() end
  124. if blockUp == false then
  125. turtle.up()
  126. else
  127. turtle.digUp()
  128. turtle.up()
  129. end
  130. currentHeight = currentHeight + 1
  131. end
  132. if currentHeight>endHeight then
  133. local blockDown = turtle.detectDown()
  134. if ladderSelection == 'y' then
  135. ladders() end
  136. if blockDown == false then
  137. turtle.down()
  138. else
  139. turtle.digDown()
  140. turtle.down()
  141. end
  142. currentHeight = currentHeight - 1
  143. end
  144. end
  145.  
  146. function moveNS()
  147. if currentNS>endNS then
  148. endDirection = 'n'
  149. compus()
  150. local blockFront = turtle.detect()
  151. if blockFront == true then
  152. turtle.dig()
  153. if tunnelSelection == 'y' then
  154. tunnels() end
  155. turtle.forward()
  156. else
  157. turtle.forward()
  158. end
  159. currentNS = currentNS -1
  160. end
  161. if currentNS<endNS then
  162. endDirection = 's'
  163. compus()
  164. local blockFront = turtle.detect()
  165. if blockFront == true then
  166. turtle.dig()
  167. if tunnelSelection == 'y' then
  168. tunnels() end
  169. turtle.forward()
  170. else
  171. turtle.forward()
  172. end
  173. currentNS = currentNS +1
  174. end
  175. end
  176. function moveWE()
  177. if currentWE>endWE then
  178. endDirection = 'w'
  179. compus()
  180. local blockFront = turtle.detect()
  181. if blockFront == true then
  182. turtle.dig()
  183. if tunnelSelection == 'y' then
  184. tunnels() end
  185. turtle.forward()
  186. else
  187. turtle.forward()
  188. end
  189. currentWE = currentWE -1
  190. end
  191. if currentWE<endWE then
  192. endDirection = 'e'
  193. compus()
  194. local blockFront = turtle.detect()
  195. if blockFront == true then
  196. turtle.dig()
  197. if tunnelSelection == 'y' then
  198. tunnels() end
  199. turtle.forward()
  200. else
  201. turtle.forward()
  202. end
  203. currentWE = currentWE +1
  204. end
  205. end
  206.  
  207. --main
  208. print("what direction is the turtle Facing? n/s/e/w:")
  209. currentDirection = read()
  210. print("Slot 2:Torches")
  211. write("do you want ladders?:")
  212. ladderSelection = read()
  213. if ladderSelection = 'y' then
  214. print("Slot 1:Ladders")
  215. print("Slot 2:Torches")
  216. end
  217. write("do you want tunnels?:")
  218. tunnelSelection = read()
  219. if tunnelSelection = 'y' then
  220. print("Slot 2:Torches")
  221. end
  222. print("Whats the Turtles current position?")
  223. write("x:") currentWE = tonumber(read())
  224. write("z:") currentNS = tonumber(read())
  225. write("y:") currentHeight = tonumber(read())
  226. print("Whats the Turtles end position?:")
  227. write("x:") endWE = tonumber(read())
  228. write("z:") endNS = tonumber(read())
  229. write("y:") endHeight = tonumber(read())
  230.  
  231. repeat
  232. moveHeight()
  233. until currentHeight == endHeight
  234. repeat
  235. moveNS()
  236. until currentNS == endNS
  237. repeat
  238. moveWE()
  239. until currentWE == endWE
  240. return()
  241. repeat
  242. moveWE()
  243. until currentWE == endWE
  244. repeat
  245. moveNS()
  246. until currentNS == endNS
  247. repeat
  248. moveHeight()
  249. until currentHeight == endHeight
  250. endDirection = 'n'
  251. compus()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement