Advertisement
Malte9799

Untitled

May 19th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.94 KB | None | 0 0
  1. local distance = 0
  2. local onlight = 0
  3. local torch = turtle.getItemCount(1)
  4. local chest = turtle.getItemCount(2)
  5. local ItemFuel = turtle.getItemCount(3)
  6. local MD = 3
  7. local MineTimes = 0
  8. local Fuel = 0
  9. local NeedFuel = 0
  10. local Error = 0
  11. local Way = 0
  12.  
  13. local function Check()
  14. if torch == 0 then
  15. print("There are no torch's in Turtle")
  16. Error = 1
  17. else
  18. print("There are torch's in turtle")
  19. end
  20. if chest == 0 then
  21. print("There are no chests")
  22. Error = 1
  23. else
  24. print("There are chest in turtle")
  25. end
  26. if ItemFuel == 0 then
  27. print("No Fuel Items")
  28. error = 1
  29. else
  30. print("There is fuel")
  31. end
  32. repeat
  33. if turtle.getFuelLevel() == "unlimited" then
  34. print("NO NEED FOR FUEL")
  35. Needfuel = 0
  36. elseif turtle.getFuelLevel() < 100 then
  37. turtle.select(3)
  38. turtle.refuel(1)
  39. turtle.select(1)
  40. Needfuel = 1
  41. ItemFuel = ItemFuel - 1
  42. elseif NeedFuel == 1 then
  43. Needfuel = 0
  44. end
  45. until NeedFuel == 0
  46. end
  47.  
  48. local function Recheck()
  49. torch = turtle.getItemCount(1)
  50. chest = turtle.getItemCount(2)
  51. ItemFuel = turtle.getItemCount(3)
  52. Error = 0
  53. end
  54.  
  55. local function WarmUpForBackProgram()
  56. turtle.turnLeft()
  57. turtle.turnLeft()
  58. repeat
  59. if turtle.detectUp() then
  60. turtle.digUp()
  61. end
  62. until turtle.up()
  63. end
  64.  
  65. local function Back()
  66. repeat
  67. if turtle.forward() then
  68. TB = TB - 1
  69. end
  70. if turtle.detect() then
  71. if TB ~= 0 then
  72. turtle.dig()
  73. end
  74. end
  75. if turtle.detectDown() then
  76. turtle.digDown()
  77. if turtle.getItemCount(1) > torch then
  78. turtle.select(1)
  79. turtle.placeDown()
  80. end
  81. end
  82. until TB == 0
  83. end
  84.  
  85. local function FillInChest()
  86. if chest > 0 then
  87. back = TB - TF
  88. WarmUpForBackProgram()
  89.  
  90. repeat
  91. if turtle.forward() then
  92. back = back - 1
  93. end
  94. if turtle.detect() then
  95. if back ~= 0 then
  96. turtle.dig()
  97. end
  98. end
  99. until back == 0
  100.  
  101. turtle.select(2)
  102. if turtle.detectDown() then
  103. turtle.digUp()
  104. end
  105. turtle.down()
  106. turtle.digDown()
  107. turtle.placeDown()
  108. chest = chest - 1
  109. for slot = 5, 16 do
  110. turtle.select(slot)
  111. turtle.dropDown()
  112. end
  113. turtle.select(1)
  114.  
  115. turtle.turnLeft()
  116. turtle.turnLeft()
  117. turtle.up()
  118.  
  119. for slot = 0, TB - TF do
  120. turtle.forward()
  121. end
  122.  
  123. turtle.down()
  124. else
  125. print("Turtle run out of chest")
  126. os.shutdown()
  127. end
  128. end
  129.  
  130.  
  131. local function ForwardM()
  132. repeat
  133. if turtle.detect() then
  134. turtle.dig()
  135. end
  136. if turtle.forward() then
  137. TF = TF - 1
  138. onlight = onlight + 1
  139. end
  140. if turtle.detectUp() then
  141. turtle.digUp()
  142. end
  143.  
  144. turtle.select(4)
  145. turtle.placeDown()
  146. turtle.select(1)
  147.  
  148. if onlight == 8 then
  149. if torch > 0 then
  150. turtle.turnLeft()
  151. turtle.turnLeft()
  152. turtle.place()
  153. turtle.turnLeft()
  154. turtle.turnLeft()
  155. torch = torch - 1
  156. onlight = onlight - 8
  157. else
  158. print("Turtle run out of torchs")
  159. os.shutdown()
  160. end
  161. end
  162.  
  163. if turtle.getItemCount(16) > 0 then
  164. FillInChest()
  165. end
  166.  
  167. repeat
  168. if turtle.getFuelLevel() == "unlimited" then
  169. print("NO NEED FOR FUEL")
  170. Needfuel = 0
  171. elseif turtle.getFuelLevel() < 100 then
  172. turtle.select(3)
  173. turtle.refuel(1)
  174. turtle.select(1)
  175. Needfuel = 1
  176. ItemFuel = ItemFuel - 1
  177. elseif ItemFuel == 0 then
  178. print("Turtle run out of fuel")
  179. os.shutdown()
  180. elseif NeedFuel == 1 then
  181. Needfuel = 0
  182. end
  183. until NeedFuel == 0
  184. until TF == 0
  185. end
  186.  
  187. local function MultiMines()
  188. if turtle.detectDown() then
  189. turtle.digDown()
  190. end
  191. if Way == 1 then
  192. turtle.turnLeft()
  193. turtle.down()
  194. else
  195. turtle.turnRight()
  196. turtle.down()
  197. end
  198. repeat
  199. if turtle.detect() then
  200. turtle.dig()
  201. end
  202. if turtle.forward() then
  203. MD = MD - 1
  204. end
  205. if turtle.detectUp() then
  206. turtle.digUp()
  207. end
  208.  
  209. turtle.select(4)
  210. turtle.placeDown()
  211. turtle.select(1)
  212.  
  213. until MD == 0
  214. if Way == 1 then
  215. turtle.turnLeft()
  216. else
  217. turtle.turnRight()
  218. end
  219. if MineTimes == 0 then
  220. print("Turtle is done")
  221. else
  222. MineTimes = MineTimes - 1
  223. end
  224. end
  225.  
  226. local function Restart()
  227. TF = distance
  228. TB = distance
  229. MD = 3
  230. end
  231.  
  232. function Start()
  233. repeat
  234. onlight = 2
  235. ForwardM()
  236. WarmUpForBackProgram()
  237. Back()
  238. MultiMines()
  239. Restart()
  240. until MineTimes == 0
  241. end
  242.  
  243. print("Hi There Welcome to Mining Turtle Program")
  244. print("How Far Will Turtle Go")
  245. input = io.read()
  246. distance = tonumber(input)
  247. TF = distance
  248. TB = distance
  249. print("Left or Right")
  250. print("0 = Left and 1 = Right")
  251. input2 = io.read()
  252. Way = tonumber(input2)
  253. print("How Many Times")
  254. input3 = io.read()
  255. MineTimes = tonumber(input3)
  256. Recheck()
  257. Check()
  258. if Error == 1 then
  259. repeat
  260. sleep(10)
  261. Recheck()
  262. Check()
  263. until Error == 0
  264. end
  265. Start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement