Advertisement
M0n5t3r

Better Miner Bot

Jun 3rd, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.36 KB | None | 0 0
  1.  
  2. --startup
  3. term.write("Insert Length: ")
  4. Length = tonumber(read())
  5. print(" ")
  6.  
  7. term.write("Insert - times 3 - Width: ")
  8. Width = tonumber(read())
  9. print(" ")
  10.  
  11. local Length = Length
  12. local Width = Width
  13.  
  14. local goRight = 0
  15.  
  16. local firstStartUp = false
  17. local times_forward = 0
  18. local time_left = 0
  19. local torch_forward = 0
  20. local torchCounter = 0
  21. --slots
  22. local torchSlot = 1
  23. local chestSlot = 2
  24.  
  25. function firstStartUp()
  26. Width = Width - 1
  27. --check if torches and a chest is set
  28. if turtle.getItemCount(torchSlot) < 1 then
  29. print("put torches in slot 1!")
  30. repeat
  31. sleep (1.1)
  32.  
  33. until turtle.getItemCount(torchSlot) > 1
  34. end
  35. if turtle.getItemCount(chestSlot) < 1 then
  36. print("put chestes in slot 2!")
  37. repeat
  38. sleep (1.1)
  39. until turtle.getItemCount(chestSlot) >= 1
  40. end
  41. turtle.digDown()
  42. turtle.select(chestSlot)
  43. turtle.placeDown()
  44.  
  45. -- mine first thing
  46. repeat
  47. turtle.digUp()
  48. until turtle.up() == true
  49. turtle.down()
  50. -- ga naar links, dig, naar voren, dig up&down
  51. turtle.turnLeft()
  52. repeat
  53. turtle.dig()
  54. until not turtle.detect() == true
  55. turtle.forward()
  56. repeat
  57. turtle.digUp()
  58. until turtle.up() == true
  59. turtle.down()
  60. turtle.digDown()
  61.  
  62. -- ga naar rechts, vooren, dig up dig up&down
  63. turtle.turnRight()
  64. turtle.turnRight()
  65. turtle.forward()
  66. repeat
  67. turtle.dig()
  68. until not turtle.detect() == true
  69. turtle.forward()
  70. repeat
  71. turtle.digUp()
  72. until turtle.up() == true
  73. turtle.down()
  74. turtle.digDown()
  75.  
  76. turtle.turnLeft()
  77. turtle.turnLeft()
  78. turtle.forward()
  79. turtle.turnRight()
  80.  
  81.  
  82. firstStartUp = true
  83. end
  84.  
  85. function mineForward()
  86. --ga een vooruit
  87. repeat
  88. turtle.dig()
  89. until not turtle.detect() == true
  90. turtle.forward()
  91. repeat
  92. turtle.digUp()
  93. until turtle.up() == true
  94. turtle.down()
  95. turtle.digDown()
  96.  
  97. -- ga naar links, dig, naar voren, dig up
  98. turtle.turnLeft()
  99. repeat
  100. turtle.dig()
  101. until not turtle.detect() == true
  102. turtle.forward()
  103. repeat
  104. turtle.digUp()
  105. until turtle.up() == true
  106. turtle.down()
  107. turtle.digDown()
  108.  
  109. -- ga naar rechts, vooren, dig up dig down
  110. turtle.turnRight()
  111. turtle.turnRight()
  112. turtle.forward()
  113. repeat
  114. turtle.dig()
  115. until not turtle.detect() == true
  116. turtle.forward()
  117. repeat
  118. turtle.digUp()
  119. until turtle.up() == true
  120. turtle.down()
  121. turtle.digDown()
  122.  
  123. -- ga weer terug naar midden positie
  124. turtle.turnLeft()
  125. turtle.turnLeft()
  126. turtle.forward()
  127. turtle.turnRight()
  128. times_forward = times_forward + 1
  129. torch_forward = torch_forward + 1
  130. doIneedAtorch()
  131. doIneedToEmpty()
  132. end
  133.  
  134. function doIneedAtorch()
  135. --check if torches not empty
  136. turtle.select(torchSlot)
  137. if turtle.getItemCount(torchSlot) < 1 then
  138. turtle.turnLeft()
  139. turtle.turnLeft()
  140. for i=1,times_forward do
  141. turtle.forward()
  142. end
  143. print("put torches in slot 1!")
  144. repeat
  145. sleep (1.1)
  146. until turtle.getItemCount(torchSlot) > 1
  147. turtle.turnLeft()
  148. turtle.turnLeft()
  149. for i=1,times_forward do
  150. turtle.forward()
  151. end
  152. end
  153.  
  154. --plaats een torch
  155. if Length > 8 then
  156. if torch_forward == 8 then
  157. turtle.select(1)
  158. turtle.placeDown()
  159. torchCounter = torchCounter + 1
  160. torch_forward = 0
  161. end
  162. end
  163. if Length < 8 then
  164. if torch_forward == Length then
  165. turtle.select(1)
  166. turtle.placeDown()
  167. torchCounter = torchCounter + 1
  168. torch_forward = 0
  169. end
  170. end
  171. end
  172.  
  173. function doIneedToEmpty()
  174. turtle.getItemCount(16)
  175. if turtle.getItemCount(16) > 0 then
  176. print("gotte go clean my inventory!")
  177. turtle.turnLeft()
  178. turtle.turnLeft()
  179. for i=1,times_forward do
  180. turtle.forward()
  181. end
  182.  
  183. if time_left == 0 then
  184. for q=2,16 do
  185. turtle.select(q)
  186. turtle.dropDown()
  187. end
  188. turtle.turnLeft()
  189. turtle.turnLeft()
  190. for i=1,times_forward do
  191. turtle.forward()
  192. end
  193. end
  194.  
  195. if time_left >= 1 then
  196. turtle.turnLeft()
  197. x = 0
  198. repeat
  199. turtle.forward()
  200. turtle.forward()
  201. turtle.forward()
  202. x = x + 1
  203. until x == time_left
  204.  
  205. for q=2,16 do
  206. turtle.select(q)
  207. turtle.dropDown()
  208. end
  209.  
  210. turtle.turnLeft()
  211. turtle.turnLeft()
  212. x = 0
  213. repeat
  214. turtle.forward()
  215. turtle.forward()
  216. turtle.forward()
  217. x = x + 1
  218. until x == time_left
  219.  
  220. turtle.turnRight()
  221.  
  222. for i=1,times_forward do
  223. turtle.forward()
  224. end
  225.  
  226.  
  227.  
  228. end
  229. end
  230. end
  231.  
  232. function goLeftbyOne()
  233. turtle.turnRight()
  234. turtle.forward()
  235.  
  236. repeat
  237. turtle.dig()
  238. until not turtle.detect() == true
  239. turtle.forward()
  240. repeat
  241. turtle.digUp()
  242. until turtle.up() == true
  243. turtle.down()
  244. turtle.digDown()
  245.  
  246. repeat
  247. turtle.dig()
  248. until not turtle.detect() == true
  249. turtle.forward()
  250. repeat
  251. turtle.digUp()
  252. until turtle.up() == true
  253. turtle.down()
  254. turtle.digDown()
  255.  
  256. repeat
  257. turtle.dig()
  258. until not turtle.detect() == true
  259. turtle.forward()
  260. repeat
  261. turtle.digUp()
  262. until turtle.up() == true
  263. turtle.down()
  264. turtle.digDown()
  265.  
  266. turtle.back()
  267.  
  268. turtle.turnRight()
  269.  
  270. time_left = time_left + 1
  271. end
  272.  
  273. function everythingDone()
  274. print("gotte go clean my inventory!")
  275. turtle.turnLeft()
  276. turtle.turnLeft()
  277. for i=1,times_forward do
  278. turtle.forward()
  279. end
  280.  
  281. if time_left == 0 then
  282. for q=2,16 do
  283. turtle.select(q)
  284. turtle.dropDown()
  285. end
  286. print("done with emptieing")
  287. end
  288.  
  289. if time_left >= 1 then
  290. turtle.turnLeft()
  291. x = 0
  292. repeat
  293. turtle.forward()
  294. turtle.forward()
  295. turtle.forward()
  296. x = x + 1
  297. until x == time_left
  298.  
  299. for q=2,16 do
  300. turtle.select(q)
  301. turtle.dropDown()
  302. end
  303. turtle.turnRight()
  304. print("done with emptieing")
  305. end
  306. end
  307.  
  308. function goBack()
  309. turtle.turnLeft()
  310. turtle.turnLeft()
  311. for i=1,times_forward do
  312. turtle.forward()
  313. end
  314. end
  315.  
  316.  
  317. print("Lets GO!")
  318. firstStartUp()
  319.  
  320. repeat
  321. repeat
  322. mineForward()
  323. until times_forward == Length
  324.  
  325. turtle.select(1)
  326. turtle.placeDown()
  327. torchCounter = torchCounter + 1
  328.  
  329. goBack()
  330.  
  331. if time_left ~= Width then
  332. goLeftbyOne()
  333. end
  334.  
  335. times_forward = 0
  336.  
  337. if time_left == Width then
  338. mineForward()
  339. end
  340.  
  341. until time_left == Width
  342.  
  343. mineForward()
  344. everythingDone()
  345.  
  346. print ("DONE")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement