DreamGamer

242453546

Dec 21st, 2016
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.93 KB | None | 0 0
  1. -- Program by DreamCoding / DreamGamer
  2. -- Youtube: /dr34m94m3r
  3. -- Web: http://DreamGamer.de
  4.  
  5. local distance = 0
  6. local torch = 0
  7.  
  8.  
  9.  
  10. function startMining(lenght)
  11.  
  12. for i1=1, lenght, 1 do
  13. dig()
  14. goForward()
  15. turnRight(1)
  16. dig()
  17. digUp()
  18. goUp()
  19. dig()
  20. digUp()
  21. goUp()
  22. dig()
  23. digDown()
  24. goDown()
  25. digDown()
  26. goDown()
  27. turnLeft(1)
  28.  
  29.  
  30. checkInv()
  31. checkFuel()
  32.  
  33. distance = distance + 1
  34. torch = torch + 1
  35.  
  36. checkLight()
  37.  
  38. print("Distance: " .. distance)
  39. end
  40.  
  41.  
  42.  
  43. end
  44.  
  45.  
  46.  
  47. function goDown()
  48. while turtle.detectDown() do
  49. turtle.digDown()
  50. sleep(0.5)
  51. end
  52.  
  53. turtle.down()
  54. end
  55.  
  56. function digUp()
  57. while turtle.detectUp() do
  58. turtle.digUp()
  59. sleep(0.5)
  60. end
  61. end
  62.  
  63. function digDown()
  64. while turtle.detectDown() do
  65. turtle.digDown()
  66. sleep(0.5)
  67. end
  68. end
  69.  
  70.  
  71.  
  72. function goUp()
  73. turtle.up()
  74. end
  75.  
  76.  
  77. function goForward()
  78. while turtle.detect() do
  79. turtle.dig()
  80. sleep(0.5)
  81. end
  82.  
  83. turtle.forward()
  84. end
  85.  
  86.  
  87. function goBack()
  88. while turtle.detect() do
  89. turtle.dig()
  90. sleep(0.5)
  91. end
  92.  
  93. turtle.back()
  94. end
  95.  
  96.  
  97. function turnRight(turnNumber)
  98. for i=1, turnNumber, 1 do
  99. turtle.turnRight()
  100. end
  101. end
  102.  
  103. function turnLeft(turnNumber)
  104. for i=1, turnNumber, 1 do
  105. turtle.turnLeft()
  106. end
  107. end
  108.  
  109.  
  110. function dig()
  111. while turtle.detect() do
  112. turtle.dig()
  113. sleep(0.5)
  114. end
  115.  
  116. end
  117.  
  118.  
  119.  
  120. function checkInv()
  121. if turtle.getItemCount(14) == 0 then
  122. while turtle.getItemCount(14) == 0 do
  123. print("Missing Ender chest!")
  124. sleep(10)
  125. end
  126. else
  127.  
  128.  
  129. if turtle.getItemCount(13) > 1 then
  130. local slot = 2
  131.  
  132.  
  133. turnRight(1)
  134. turtle.select(14)
  135. turtle.place()
  136.  
  137. print("Clear Inventory...")
  138.  
  139. while turtle.getItemCount(13) > 0 do
  140. turtle.select(slot)
  141. sleep(0.2)
  142.  
  143. if turtle.detect() then
  144. turtle.drop(64)
  145. else
  146. print("No chest?")
  147. end -- if
  148.  
  149. slot = slot + 1
  150. end -- while
  151.  
  152. turtle.select(14)
  153. turtle.dig()
  154. turtle.select(1)
  155. turnLeft(1)
  156.  
  157. print("Inventory cleared!")
  158. end -- if
  159. end -- if
  160. end -- function
  161.  
  162.  
  163. function checkFuel()
  164.  
  165. if turtle.getFuelLevel() < 10 then
  166. turtle.select(15)
  167. print("Out of Fuel! Try to get Fuel...")
  168. print("Fuel Level:" .. turtle.getFuelLevel())
  169. turtle.refuel(64)
  170. turtle.select(1)
  171.  
  172. for i2=1, 13, 1 do
  173.  
  174. turtle.select(i2)
  175. if turtle.refuel(0) then
  176. turtle.refuel(64)
  177. print("Fuel Level:" .. turtle.getFuelLevel())
  178. end -- if
  179. end -- for
  180. end -- if
  181. end -- function
  182.  
  183.  
  184. function checkLight()
  185.  
  186. if torch == 5 then
  187. turnRight(1)
  188. up()
  189. goUp()
  190. turtle.select(16)
  191. goForward()
  192.  
  193. if not turtle.detect() then
  194. turtle.select(1)
  195. turtle.place()
  196. turtle.select(16)
  197. end -- if
  198.  
  199. turnLeft(2)
  200. dig()
  201. goForward()
  202. turnRight(2)
  203. turtle.place()
  204. turnLeft(1)
  205. digDown()
  206. goDown()
  207.  
  208.  
  209. torch = 0
  210. end -- if
  211.  
  212. end -- function
  213.  
  214.  
  215.  
  216. print("Mining lenght: ")
  217.  
  218. local lenght = read()
  219.  
  220. startMining(lenght)
Advertisement
Add Comment
Please, Sign In to add comment