Advertisement
JMANN2400

branchMods

Nov 18th, 2019
481
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.25 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,15,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,15,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" or data.name == "projectred-exploration:ore" or data.name == "thermalfoundation: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" or data.name == "projectred-exploration:ore" or data.name == "thermalfoundation: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" or data.name == "projectred-exploration:ore" or data.name == "thermalfoundation:ore" then
  59. print("I found ", data.name, "!")
  60. return true
  61. end
  62. end
  63.  
  64. function checkLavaCheck()
  65. success, data = turtle.inspect()
  66. if data.name == "minecraft:lava" then
  67. return true
  68. end
  69. end
  70.  
  71. function checkLavaCheckUp()
  72. success, data = turtle.inspectUp()
  73. if data.name == "minecraft:lava" then
  74. if y == h - 1 then
  75. return true
  76. end
  77. end
  78. end
  79.  
  80. function checkLavaCheckDown()
  81. success, data = turtle.inspectDown()
  82. if data.name == "minecraft:lava" then
  83. if y == 0 then
  84. return true
  85. end
  86. end
  87. end
  88.  
  89. function check()
  90. print("I'm gonna check for some ore and lava!")
  91. print("Checking in front of me!")
  92. if checkWanted() then
  93. while turtle.detect() do
  94. turtle.dig()
  95. end
  96. turtle.forward()
  97. checks = checks + 1
  98. check()
  99. turtle.back()
  100. checks = checks - 1
  101. end
  102. if checkLavaCheck() then
  103. print("I found some in front of me!")
  104. turtle.select(16)
  105. print(turtle.place())
  106. print(turtle.refuel())
  107. print("My fuel level is at ", turtle.getFuelLevel(), ".")
  108. end
  109. print("Checking to my left!")
  110. turtle.turnLeft()
  111. if checkWanted() then
  112. while turtle.detect() do
  113. turtle.dig()
  114. end
  115. turtle.forward()
  116. checks = checks + 1
  117. check()
  118. turtle.back()
  119. checks = checks - 1
  120. end
  121. if checkLavaCheck() then
  122. print("I found some to my left!")
  123. turtle.select(16)
  124. print(turtle.place())
  125. print(turtle.refuel())
  126. print("My fuel level is at ", turtle.getFuelLevel(), ".")
  127. if checks == 0 then
  128. turtle.select(2)
  129. turtle.place()
  130. end
  131. end
  132. print("Checking to my right!")
  133. turtle.turnRight()
  134. turtle.turnRight()
  135. if checkWanted() then
  136. while turtle.detect() do
  137. turtle.dig()
  138. end
  139. turtle.forward()
  140. checks = checks + 1
  141. check()
  142. turtle.back()
  143. checks = checks - 1
  144. end
  145. if checkLavaCheck() then
  146. print("I found some to my right!")
  147. turtle.select(16)
  148. print(turtle.place())
  149. print(turtle.refuel())
  150. print("My fuel level is at ", turtle.getFuelLevel(), ".")
  151. if checks == 0 then
  152. turtle.select(2)
  153. turtle.place()
  154. end
  155. end
  156. turtle.turnLeft()
  157. print("Checking above me!")
  158. if checkWantedUp() then
  159. turtle.digUp()
  160. turtle.turnLeft()
  161. turtle.turnLeft()
  162. turtle.turnLeft()
  163. turtle.turnLeft()
  164. turtle.up()
  165. checks = checks + 1
  166. check()
  167. turtle.down()
  168. checks = checks - 1
  169. end
  170. if checkLavaCheckUp() then
  171. print("I found some above me!")
  172. turtle.select(16)
  173. turtle.placeUp()
  174. turtle.refuel()
  175. print("My fuel level is at ", turtle.getFuelLevel(), ".")
  176. if checks == 0 then
  177. turtle.select(2)
  178. turtle.placeUp()
  179. end
  180. end
  181. print("Checking below me!")
  182. if checkWantedDown() then
  183. turtle.digDown()
  184. turtle.down()
  185. checks = checks + 1
  186. check()
  187. turtle.up()
  188. checks = checks - 1
  189. end
  190. if checkLavaCheckDown() then
  191. print("I found some below me!")
  192. turtle.select(16)
  193. turtle.placeDown()
  194. turtle.refuel()
  195. print("My fuel level is at ", turtle.getFuelLevel(), ".")
  196. if checks == 0 then
  197. turtle.select(2)
  198. turtle.placeDown()
  199. end
  200. end
  201. end
  202.  
  203. function mine()
  204. turtle.select(15)
  205. turtle.refuel()
  206. turtle.select(1)
  207. print("My fuel level is at ", turtle.getFuelLevel(), ".")
  208. print("I have ", getCount(), " items.")
  209.  
  210. if turtle.detect() == true then
  211. turtle.dig()
  212. end
  213. for a = 1, h-1, 1 do
  214. if turtle.detectUp() then
  215. turtle.digUp()
  216. end
  217. if turtle.up() then
  218. y = y + 1
  219. end
  220. if turtle.detect() == true then
  221. turtle.dig()
  222. end
  223. end
  224. check()
  225. while y > 0 do
  226. if turtle.down() then
  227. y = y - 1
  228. end
  229. check()
  230. end
  231. if turtle.detectDown() == false then
  232. turtle.select(2)
  233. turtle.placeDown()
  234. end
  235. while turtle.detect() do
  236. turtle.dig()
  237. end
  238. turtle.forward()
  239. z = z + 1
  240. if getCount() > 320 then
  241. deposit()
  242. end
  243. if z + h * 4 > turtle.getFuelLevel() then
  244. while z > 0 do
  245. turtle.back()
  246. z = z - 1
  247. print("Low on fuel!")
  248. print("Fuel level = ", turtle.getFuelLevel())
  249. end
  250. print("Please insert more fuel in slot 15!")
  251. read()
  252. turtle.select(15)
  253. turtle.refuel()
  254. turtle.select(1)
  255. end
  256. if z > 0 then
  257. print("I'm ", z,"/", l, " of the way done.")
  258. end
  259. end
  260.  
  261. function sideMine()
  262. turtle.select(15)
  263. turtle.refuel()
  264. turtle.select(1)
  265. print("My fuel level is at ", turtle.getFuelLevel(), ".")
  266. print("I have ", getCount(), " items.")
  267.  
  268. if turtle.detect() == true then
  269. turtle.dig()
  270. end
  271. for a = 1, h-1, 1 do
  272. if turtle.detectUp() then
  273. turtle.digUp()
  274. end
  275. if turtle.up() then
  276. y = y + 1
  277. end
  278. if turtle.detect() == true then
  279. turtle.dig()
  280. end
  281. end
  282. check()
  283. while y > 0 do
  284. if turtle.down() then
  285. y = y - 1
  286. end
  287. check()
  288. end
  289. if turtle.detectDown() == false then
  290. turtle.select(2)
  291. turtle.placeDown()
  292. end
  293. while turtle.detect() do
  294. turtle.dig()
  295. end
  296. turtle.forward()
  297. x = x + 1
  298. if getCount() > 320 then
  299. deposit()
  300. end
  301. end
  302.  
  303.  
  304.  
  305. print("+-------------------------------------+")
  306. print("| Branch Mine |")
  307. print("+-------------------------------------+")
  308. print("| Slot 15: Fuel |")
  309. print("| Slot 16: Empty Bucket |")
  310. print("| Slot 1: Chests |")
  311. print("| Slot 2: Blocks |")
  312. print("+-------------------------------------+")
  313. print("| Place turtle at start of mine. |")
  314. print("| Insert fuel. Specify height and |")
  315. print("| length. Press enter to start. |")
  316. print("+-------------------------------------+")
  317. read()
  318. print("+-------------------------------------+")
  319. print("| Mine length = ? |")
  320. print("+-------------------------------------+")
  321. l = tonumber(read())
  322. print("+-------------------------------------+")
  323. print("| Mine height = ? (>=2) |")
  324. print("+-------------------------------------+")
  325. h = tonumber(read())
  326. print("+-------------------------------------+")
  327. print("| Amount of shafts = ? |")
  328. print("+-------------------------------------+")
  329. m = tonumber(read())
  330.  
  331. while z < l do
  332. mine()
  333. end
  334. turtle.turnLeft()
  335. turtle.turnLeft()
  336. while z > 0 do
  337. turtle.dig()
  338. turtle.forward()
  339. z = z - 1
  340. end
  341. turtle.turnLeft()
  342. mined = mined + 1
  343.  
  344. while mined < m do
  345. sideMine()
  346. sideMine()
  347. sideMine()
  348. turtle.turnLeft()
  349. while z < l do
  350. mine()
  351. end
  352. turtle.turnLeft()
  353. turtle.turnLeft()
  354. while z > 0 do
  355. turtle.dig()
  356. turtle.forward()
  357. z = z - 1
  358. end
  359. turtle.turnLeft()
  360. mined = mined + 1
  361. end
  362. turtle.turnLeft()
  363. turtle.turnLeft()
  364. while x > 0 do
  365. turtle.dig()
  366. turtle.forward()
  367. x = x - 1
  368. end
  369. turtle.turnRight()
  370.  
  371. print("I put down ", chestsDropped, " chests for you.")
  372. print("My fuel level is at ", turtle.getFuelLevel(), ".")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement