Advertisement
LoganRusinek

Untitled

Mar 29th, 2020
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.14 KB | None | 0 0
  1. --[[VARIABLES]]--
  2.  
  3. local mineHeight = 0;
  4. local run = true;
  5. local currentRotation = 0
  6. local currentYPosition = 0
  7. local currentZPosition = 0
  8.  
  9. local oldYPosition = 0
  10. local oldZPosition = 0
  11. local oldRotation = 0
  12.  
  13.  
  14.  
  15. --[[BASIC FUNCTIONS]]--
  16.  
  17. function updateScreen()
  18. term.clear()
  19. term.setCursorPos(1, 1)
  20. print("LOGAN'S MINING SYSTEM")
  21. print("Y: " .. currentYPosition)
  22. print("Z: " .. currentZPosition)
  23. print("ROTATION: " .. currentRotation)
  24. print("FUEL: " .. turtle.getFuelLevel() .. " / " .. turtle.getFuelLimit())
  25. print("OLD Y POSTIION: " .. oldYPosition)
  26. print("OLD Z POSITION: " .. oldZPosition)
  27. end
  28.  
  29.  
  30. function turnLeft()
  31. currentRotation = currentRotation - 1;
  32. turtle.turnLeft()
  33. end
  34.  
  35.  
  36. function turnRight()
  37. currentRotation = currentRotation + 1;
  38. turtle.turnRight()
  39. end
  40.  
  41.  
  42. function dig()
  43. updateScreen()
  44.  
  45. if turtle.getItemCount(16) == 0 then
  46. turtle.dig()
  47. else
  48. returnToHome()
  49. deposit()
  50. returnToOldPosition()
  51. turtle.dig()
  52. end
  53. end
  54.  
  55.  
  56. function digUp()
  57. updateScreen()
  58.  
  59. if turtle.getItemCount(16) == 0 then
  60. turtle.digUp()
  61. else
  62. returnToHome()
  63. deposit()
  64. returnToOldPosition()
  65. end
  66. end
  67.  
  68.  
  69. function digDown()
  70. updateScreen()
  71.  
  72. if turtle.getItemCount(16) == 0 then
  73. turtle.digDown()
  74. else
  75. returnToHome()
  76. deposit()
  77. returnToOldPosition()
  78. end
  79. end
  80.  
  81.  
  82. function deposit()
  83. for i = 1, 16 do
  84. turtle.select(i)
  85. turtle.drop()
  86. end
  87.  
  88. turtle.select(1)
  89. end
  90.  
  91.  
  92. function forward()
  93. updateScreen()
  94.  
  95. turtle.forward()
  96.  
  97. if currentRotation == 0 then
  98. currentZPosition = currentZPosition + 1
  99. elseif currentRotation == 1 then
  100. currentXPosition = currentXPosition + 1
  101. elseif currentRotation == -1 then
  102. currentXPosition = currentXPosition - 1
  103. else
  104. currentZPosition = currentZPosition - 1
  105. end
  106. end
  107.  
  108.  
  109. --[[MOVEMENT ACTIONS]]--
  110.  
  111. function oddLevelDig()
  112. dig()
  113. turnRight()
  114. dig()
  115. turnRight()
  116. dig()
  117. end
  118.  
  119.  
  120. function evenLevelDig()
  121. dig()
  122. turnLeft()
  123. dig()
  124. turnLeft()
  125. dig()
  126. end
  127.  
  128.  
  129. function turnStraight()
  130. if currentRotation > 0 then
  131. repeat
  132. turnLeft()
  133. until currentRotation == 0
  134. else
  135. repeat
  136. turnRight()
  137. until currentRotation == 0
  138. end
  139. end
  140.  
  141.  
  142. function turnBackwards()
  143. if currentRotation > 0 then
  144. repeat
  145. turnRight()
  146. until currentRotation == 2
  147. else
  148. repeat
  149. turnLeft()
  150. until currentRotation == -2
  151. end
  152. end
  153.  
  154.  
  155. function returnToHome()
  156. oldRotation = currentRotation
  157. oldYPosition = currentYPosition
  158. oldZPosition = currentZPosition
  159.  
  160. turnBackwards()
  161.  
  162. repeat
  163. forward()
  164. until currentZPosition == 0
  165.  
  166. for i = 1, currentYPosition do
  167. turtle.down()
  168. end
  169. end
  170.  
  171.  
  172. function returnToOldPosition()
  173. turnStraight()
  174.  
  175. repeat
  176. forward()
  177. until currentZPosition == oldZPosition
  178.  
  179. for i = 1, currentYPosition do
  180. turtle.up()
  181. end
  182.  
  183. if oldRotation == -1 then
  184. turnLeft()
  185. else
  186. turnRight()
  187. end
  188. end
  189.  
  190.  
  191.  
  192. write("Mine Height: ")
  193. mineHeight = tonumber(read());
  194.  
  195. turtle.select(1)
  196. turtle.refuel()
  197.  
  198.  
  199.  
  200. while run do
  201. turnLeft()
  202.  
  203. for i = 1, mineHeight do
  204. if i % 2 == 1 then
  205. oddLevelDig()
  206. else
  207. evenLevelDig()
  208. end
  209.  
  210. if i ~= mineHeight then
  211. digUp()
  212. turtle.up()
  213. currentYPosition = currentYPosition + 1
  214. end
  215. end
  216.  
  217. turnStraight()
  218. forward()
  219. turnLeft()
  220.  
  221. for i = mineHeight, 1, -1 do
  222. if i % 2 == 1 then
  223. oddLevelDig()
  224. else
  225. evenLevelDig()
  226. end
  227.  
  228. if i ~= 1 then
  229. digDown()
  230. turtle.down()
  231. currentYPosition = currentYPosition - 1
  232. end
  233.  
  234. end
  235.  
  236. turnStraight()
  237. forward()
  238. end
  239.  
  240. --loadstring(http.get("https://pastebin.com/raw/EpEm4WZ3").readAll())()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement