Advertisement
visiongaming43

Untitled

Feb 22nd, 2021
37
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.60 KB | None | 0 0
  1. -- Saving the first coordinate of the turtle BEFORE program starts
  2.  
  3. print("Currently saving location!")
  4.  
  5. local x1, y1, z1 = gps.locate()
  6.  
  7. print("How far do you want me to go mining?\n")
  8. local length = io.read()
  9.  
  10. function checkUp()
  11. local success, data = turtle.inspectUp()
  12. if ((success) and (data.name == "minecraft:diamond_ore" or data.name == "minecraft:coal_ore" or data.name == "minecraft:redstone_ore" or data.name == "minecraft:emerald_ore" or data.name == "minecraft:lapis_ore" or data.name == "minecraft:iron_ore" or data.name == "minecraft:ancient_debris")) then
  13. turtle.digUp()
  14. turtle.up()
  15. end
  16. end
  17.  
  18. function checkLeft()
  19. turtle.turnLeft()
  20. local success, data = turtle.inspect()
  21. if ((success) and (data.name == "minecraft:diamond_ore" or data.name == "minecraft:coal_ore" or data.name == "minecraft:redstone_ore" or data.name == "minecraft:emerald_ore" or data.name == "minecraft:lapis_ore" or data.name == "minecraft:iron_ore" or data.name == "minecraft:ancient_debris")) then
  22. turtle.dig()
  23. turtle.forward()
  24. turtle.turnRight()
  25. else
  26. turtle.turnRight()
  27. end
  28. end
  29.  
  30. function checkRight()
  31. turtle.turnRight()
  32. local success, data = turtle.inspect()
  33. if ((success) and (data.name == "minecraft:diamond_ore" or data.name == "minecraft:coal_ore" or data.name == "minecraft:redstone_ore" or data.name == "minecraft:emerald_ore" or data.name == "minecraft:lapis_ore" or data.name == "minecraft:iron_ore" or data.name == "minecraft:ancient_debris")) then
  34. turtle.dig()
  35. turtle.forward()
  36. else
  37. turtle.turnLeft()
  38. end
  39. end
  40.  
  41. function checkDown()
  42. local success, data = turtle.inspectDown()
  43. if ((success) and (data.name == "minecraft:diamond_ore" or data.name == "minecraft:coal_ore" or data.name == "minecraft:redstone_ore" or data.name == "minecraft:emerald_ore" or data.name == "minecraft:lapis_ore" or data.name == "minecraft:iron_ore" or data.name == "minecraft:ancient_debris")) then
  44. turtle.digDown()
  45. turtle.Down()
  46. end
  47. end
  48.  
  49. function checkFront()
  50. local success, data = turtle.inspect()
  51. if ((success) and (data.name == "minecraft:diamond_ore" or data.name == "minecraft:coal_ore" or data.name == "minecraft:redstone_ore" or data.name == "minecraft:emerald_ore" or data.name == "minecraft:lapis_ore" or data.name == "minecraft:iron_ore" or data.name == "minecraft:ancient_debris")) then
  52. turtle.dig()
  53. turtle.forward()
  54. end
  55. end
  56. -- Side note : Kill urself after ur done with this fucking stupid shit mining program
  57.  
  58. for a = length, 1, -1
  59. do
  60. turtle.dig()
  61. turtle.forward()
  62.  
  63. local xNew, yNew, zNew = gps.locate()
  64. checkUp()
  65. checkUp()
  66. checkUp()
  67. checkUp()
  68. for 3, 1, -1
  69. do
  70. turtle.down()
  71. end
  72. checkLeft()
  73. checkLeft()
  74. checkLeft()
  75. turtle.turnRight()
  76. for 3, 1, -1
  77. do
  78. turtle.forward()
  79. end
  80. turtle.turnLeft()
  81. -- Seperate cuz my mind stupid
  82.  
  83. checkDown()
  84.  
  85. -- Seperate cuz my mind stupid
  86.  
  87. checkLeft()
  88.  
  89. -- Seperate cuz my mind stupid
  90.  
  91. checkRight()
  92.  
  93. end
  94.  
  95. -- Saving the coordinaates of the turtle AS SOON AS IT'S DONE mining
  96.  
  97. local x2, y2, z2 = gps.locate()
  98.  
  99. -- If the new x-coord is less than the first, then go West (vice versa)
  100.  
  101. if x2 < x1 then
  102. goEast = true
  103. goWest = false
  104. elseif x2 > x1 then
  105. goWest = true
  106. goEast = false
  107. else
  108. goEast = false
  109. goWest = false
  110. end
  111.  
  112. -- If the new y-coord is less than the first, then go Up (vice versa)
  113.  
  114. if y2 < y1 then
  115. goUp = true
  116. goDown = false
  117. elseif y2 > y1 then
  118. goDown = true
  119. goUp = false
  120. else
  121. goDown = false
  122. goUp = false
  123. end
  124.  
  125. -- If the new z-coord is less than the first, then go North (vice versa)
  126.  
  127. if z2 < z1 then
  128. goSouth = true
  129. goNorth = false
  130. elseif z2 > z1 then
  131. goNorth = true
  132. goSouth = false
  133. else
  134. goSouth = false
  135. goNorth = false
  136. end
  137.  
  138. -- While a block is in front, dig
  139.  
  140. while turtle.detect() == true
  141. do
  142. turtle.dig()
  143. end
  144.  
  145. -- Move forward ONCE
  146.  
  147. turtle.forward()
  148.  
  149. -- Refresh GPS location (for calibrating direction of turtle)
  150.  
  151. local x3, y3, z3 = gps.locate()
  152.  
  153. -- If the turtle's x-coordinate gets bigger, it is facing East (vice versa)
  154.  
  155. if x3 > x2 then
  156. faceEast = true
  157. faceWest = false
  158. faceNorth = false
  159. faceSouth = false
  160. elseif x3 < x2 then
  161. faceWest = true
  162. faceEast = false
  163. faceNorth = false
  164. faceSouth = false
  165. end
  166.  
  167. -- If the turtle's z-coordinate gets bigger, it is facing South (vice versa)
  168.  
  169. if z3 > z2 then
  170. faceSouth = true
  171. faceNorth = false
  172. faceEast = false
  173. faceWest = false
  174. elseif z3 < z2 then
  175. faceNorth = true
  176. faceSouth = false
  177. faceEast = false
  178. faceWest = false
  179. end
  180.  
  181. -- Match z-coords to the beginning position
  182. if ((faceNorth == true and goNorth == true) or (faceSouth == true and goSouth == true)) then
  183. for a = math.abs(z3 - z1), 1, -1
  184. do
  185. while turtle.detect() == true
  186. do
  187. turtle.dig()
  188. end
  189. turtle.forward()
  190. end
  191. end
  192. if ((faceNorth == true and goSouth == true) or (faceSouth == true and goNorth == true)) then
  193. turtle.turnRight()
  194. turtle.turnRight()
  195.  
  196. for b = math.abs(z3 - z1), 1, -1
  197. do
  198. while turtle.detect() == true
  199. do
  200. turtle.dig()
  201. end
  202. turtle.forward()
  203. end
  204. end
  205.  
  206. -- Match x-coords to the beginning position
  207. if ((faceEast == true and goEast == true) or (faceWest == true and goWest == true)) then
  208. for c = math.abs(x3 - x1), 1, -1
  209. do
  210. while turtle.detect() == true
  211. do
  212. turtle.dig()
  213. end
  214. turtle.forward()
  215. end
  216. end
  217. if ((faceEast == true and goWest == true) or (faceWest == true and goEast == true)) then
  218. turtle.turnRight()
  219. turtle.turnRight()
  220.  
  221. for d = math.abs(x3 - x1), 1, -1
  222. do
  223. while turtle.detect() == true
  224. do
  225. turtle.dig()
  226. end
  227. turtle.forward()()
  228. end
  229. end
  230.  
  231. -- Match y-coords to the beginning position
  232. if (goUp == true) then
  233. for e = math.abs(y3 - y1), 1, -1
  234. do
  235. while turtle.detectUp() == true
  236. do
  237. turtle.digUp()
  238. end
  239. turtle.Up()
  240. end
  241. end
  242. if (goDown == true) then
  243. for f = math.abs(y3 - y1), 1, -1
  244. do
  245. while turtle.detectDown() == true
  246. do
  247. turtle.digDown()
  248. end
  249. turtle.Down()
  250. end
  251. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement