Advertisement
JMANN2400

BranchMiner[NoFuel]

Aug 17th, 2017
462
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.65 KB | None | 0 0
  1.  
  2.  
  3. x = 0
  4.  
  5. y = 0
  6.  
  7. z = 0
  8.  
  9. checks = 0
  10.  
  11. chestsDropped = 0
  12.  
  13. mined = 0
  14.  
  15. function getCount()
  16. count = 0
  17. for i = 3,16,1 do
  18. count = count + turtle.getItemCount(i)
  19. end
  20. return count
  21. end
  22.  
  23. function deposit()
  24. turtle.select(1)
  25. turtle.turnLeft()
  26. turtle.dig()
  27. turtle.digUp()
  28. turtle.up()
  29. turtle.dig()
  30. turtle.down()
  31. turtle.place()
  32. chestsDropped = chestsDropped + 1
  33. for i = 3,16,1 do
  34. turtle.select(i)
  35. turtle.drop()
  36. end
  37. turtle.turnRight()
  38. end
  39.  
  40. function checkWanted()
  41. success, data = turtle.inspect()
  42. if data.name == "minecraft:diamond_ore" or data.name == "minecraft:redstone_ore" or data.name == "minecraft:iron_ore" or data.name == "minecraft:coal_ore" or data.name == "minecraft:gold_ore" or data.name == "minecraft:lapis_ore" then
  43. print("I found ", data.name, "!")
  44. return true
  45. end
  46. end
  47.  
  48. function checkWantedUp()
  49. success, data = turtle.inspectUp()
  50. if data.name == "minecraft:diamond_ore" or data.name == "minecraft:redstone_ore" or data.name == "minecraft:iron_ore" or data.name == "minecraft:coal_ore" or data.name == "minecraft:gold_ore" or data.name == "minecraft:lapis_ore" then
  51. print("I found ", data.name, "!")
  52. return true
  53. end
  54. end
  55.  
  56. function checkWantedDown()
  57. success, data = turtle.inspectDown()
  58. if data.name == "minecraft:diamond_ore" or data.name == "minecraft:redstone_ore" or data.name == "minecraft:iron_ore" or data.name == "minecraft:coal_ore" or data.name == "minecraft:gold_ore" or data.name == "minecraft:lapis_ore" then
  59. print("I found ", data.name, "!")
  60. return true
  61. end
  62. end
  63.  
  64.  
  65.  
  66. function check()
  67. print("I'm gonna check for some ore!")
  68. print("Checking in front of me!")
  69. if checkWanted() then
  70. while turtle.detect() do
  71. turtle.dig()
  72. end
  73. turtle.forward()
  74. checks = checks + 1
  75. check()
  76. turtle.back()
  77. checks = checks - 1
  78. end
  79. print("Checking to my left!")
  80. turtle.turnLeft()
  81. if checkWanted() then
  82. while turtle.detect() do
  83. turtle.dig()
  84. end
  85. turtle.forward()
  86. checks = checks + 1
  87. check()
  88. turtle.back()
  89. checks = checks - 1
  90. end
  91. print("Checking to my right!")
  92. turtle.turnRight()
  93. turtle.turnRight()
  94. if checkWanted() then
  95. while turtle.detect() do
  96. turtle.dig()
  97. end
  98. turtle.forward()
  99. checks = checks + 1
  100. check()
  101. turtle.back()
  102. checks = checks - 1
  103. end
  104. turtle.turnLeft()
  105. print("Checking above me!")
  106. if checkWantedUp() then
  107. turtle.digUp()
  108. turtle.turnLeft()
  109. turtle.turnLeft()
  110. turtle.turnLeft()
  111. turtle.turnLeft()
  112. turtle.up()
  113. checks = checks + 1
  114. check()
  115. turtle.down()
  116. checks = checks - 1
  117. end
  118. print("Checking below me!")
  119. if checkWantedDown() then
  120. turtle.digDown()
  121. turtle.down()
  122. checks = checks + 1
  123. check()
  124. turtle.up()
  125. checks = checks - 1
  126. end
  127. end
  128.  
  129. function mine()
  130. turtle.select(1)
  131. print("I have ", getCount(), " items.")
  132.  
  133. if turtle.detect() == true then
  134. turtle.dig()
  135. end
  136. for a = 1, h-1, 1 do
  137. if turtle.detectUp() then
  138. turtle.digUp()
  139. end
  140. if turtle.up() then
  141. y = y + 1
  142. end
  143. if turtle.detect() == true then
  144. turtle.dig()
  145. end
  146. end
  147. check()
  148. while y > 0 do
  149. if turtle.down() then
  150. y = y - 1
  151. end
  152. check()
  153. end
  154. if turtle.detectDown() == false then
  155. turtle.select(2)
  156. turtle.placeDown()
  157. end
  158. while turtle.detect() do
  159. turtle.dig()
  160. end
  161. turtle.forward()
  162. z = z + 1
  163. if getCount() > 320 then
  164. deposit()
  165. end
  166. if z > 0 then
  167. print("I'm ", z,"/", l, " of the way done.")
  168. end
  169. end
  170.  
  171. function sideMine()
  172. turtle.select(1)
  173. print("I have ", getCount(), " items.")
  174.  
  175. if turtle.detect() == true then
  176. turtle.dig()
  177. end
  178. for a = 1, h-1, 1 do
  179. if turtle.detectUp() then
  180. turtle.digUp()
  181. end
  182. if turtle.up() then
  183. y = y + 1
  184. end
  185. if turtle.detect() == true then
  186. turtle.dig()
  187. end
  188. end
  189. check()
  190. while y > 0 do
  191. if turtle.down() then
  192. y = y - 1
  193. end
  194. check()
  195. end
  196. if turtle.detectDown() == false then
  197. turtle.select(2)
  198. turtle.placeDown()
  199. end
  200. while turtle.detect() do
  201. turtle.dig()
  202. end
  203. turtle.forward()
  204. x = x + 1
  205. if getCount() > 320 then
  206. deposit()
  207. end
  208. end
  209.  
  210.  
  211.  
  212. print("+-------------------------------------+")
  213. print("| Branch Mine |")
  214. print("+-------------------------------------+")
  215. print("| Slot 1: Chests |")
  216. print("| Slot 2: Blocks |")
  217. print("+-------------------------------------+")
  218. print("| Place turtle at start of mine. |")
  219. print("| Insert fuel. Specify height and |")
  220. print("| length. Press enter to start. |")
  221. print("+-------------------------------------+")
  222. read()
  223. print("+-------------------------------------+")
  224. print("| Mine length = ? |")
  225. print("+-------------------------------------+")
  226. l = tonumber(read())
  227. print("+-------------------------------------+")
  228. print("| Mine height = ? (>=2) |")
  229. print("+-------------------------------------+")
  230. h = tonumber(read())
  231. print("+-------------------------------------+")
  232. print("| Amount of shafts = ? |")
  233. print("+-------------------------------------+")
  234. m = tonumber(read())
  235.  
  236. while z < l do
  237. mine()
  238. end
  239. turtle.turnLeft()
  240. turtle.turnLeft()
  241. while z > 0 do
  242. turtle.dig()
  243. turtle.forward()
  244. z = z - 1
  245. end
  246. turtle.turnLeft()
  247. mined = mined + 1
  248.  
  249. while mined < m do
  250. sideMine()
  251. sideMine()
  252. sideMine()
  253. turtle.turnLeft()
  254. while z < l do
  255. mine()
  256. end
  257. turtle.turnLeft()
  258. turtle.turnLeft()
  259. while z > 0 do
  260. turtle.dig()
  261. turtle.forward()
  262. z = z - 1
  263. end
  264. turtle.turnLeft()
  265. mined = mined + 1
  266. end
  267. turtle.turnLeft()
  268. turtle.turnLeft()
  269. while x > 0 do
  270. turtle.dig()
  271. turtle.forward()
  272. x = x - 1
  273. end
  274. turtle.turnRight()
  275.  
  276. print("I put down ", chestsDropped, " chests for you.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement