Advertisement
M0n5t3r

new_miner_bot

Mar 21st, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.31 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. turtle.select(2)
  231. end
  232.  
  233. function goLeftbyOne()
  234. turtle.turnRight()
  235. turtle.forward()
  236.  
  237. repeat
  238. turtle.dig()
  239. until not turtle.detect() == true
  240. turtle.forward()
  241. repeat
  242. turtle.digUp()
  243. until turtle.up() == true
  244. turtle.down()
  245. turtle.digDown()
  246.  
  247. repeat
  248. turtle.dig()
  249. until not turtle.detect() == true
  250. turtle.forward()
  251. repeat
  252. turtle.digUp()
  253. until turtle.up() == true
  254. turtle.down()
  255. turtle.digDown()
  256.  
  257. repeat
  258. turtle.dig()
  259. until not turtle.detect() == true
  260. turtle.forward()
  261. repeat
  262. turtle.digUp()
  263. until turtle.up() == true
  264. turtle.down()
  265. turtle.digDown()
  266.  
  267. turtle.back()
  268.  
  269. turtle.turnRight()
  270.  
  271. time_left = time_left + 1
  272. end
  273.  
  274. function everythingDone()
  275. print("gotte go clean my inventory!")
  276. turtle.turnLeft()
  277. turtle.turnLeft()
  278. for i=1,times_forward do
  279. turtle.forward()
  280. end
  281.  
  282. if time_left == 0 then
  283. for q=2,16 do
  284. turtle.select(q)
  285. turtle.dropDown()
  286. end
  287. print("done with emptieing")
  288. end
  289.  
  290. if time_left >= 1 then
  291. turtle.turnLeft()
  292. x = 0
  293. repeat
  294. turtle.forward()
  295. turtle.forward()
  296. turtle.forward()
  297. x = x + 1
  298. until x == time_left
  299.  
  300. for q=2,16 do
  301. turtle.select(q)
  302. turtle.dropDown()
  303. end
  304. turtle.turnRight()
  305. print("done with emptieing")
  306. end
  307. end
  308.  
  309. function goBack()
  310. turtle.turnLeft()
  311. turtle.turnLeft()
  312. for i=1,times_forward do
  313. turtle.forward()
  314. end
  315. end
  316.  
  317.  
  318. print("Lets GO!")
  319. firstStartUp()
  320.  
  321. repeat
  322. repeat
  323. mineForward()
  324. until times_forward == Length
  325.  
  326. turtle.select(1)
  327. turtle.placeDown()
  328. torchCounter = torchCounter + 1
  329.  
  330. goBack()
  331.  
  332. if time_left ~= Width then
  333. goLeftbyOne()
  334. end
  335.  
  336. times_forward = 0
  337.  
  338. until time_left == Width
  339.  
  340. mineForward()
  341. everythingDone()
  342.  
  343. print ("DONE")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement