Advertisement
Sparkybearbomb

Turtle Chunk Miner

Aug 17th, 2017
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- Turtle Miner
  2. -- by SparkyBearBomb
  3. --
  4. -- feel free to use this code
  5. --
  6. -- edit mining constraints here
  7.  
  8. local X = 16 -- Forward and Backwards (away from placed position)
  9. local Y = 20 -- Up and Down
  10. local Z = 16 -- Left and Right
  11.  
  12. -- X and Z are set for a chunk size (16 blocks)
  13. -- use F9 key to see chunk borders
  14. -- ensure the first block is pre mined by hand
  15. -- coal will be required in slot 1
  16.  
  17. -----------------------------------------------
  18. --Turtle Miner - Version History
  19. --
  20. -- Version 1.1 - 18 AUG 17
  21. -- - Initial Version Release
  22.  
  23. -----------------------------------------------
  24.  
  25. x = 1
  26. y = 1
  27. z = 1
  28.  
  29. running = "yes"
  30. direction = "up"
  31.  
  32. function mineX()
  33.   while turtle.detect() == true do
  34.     turtle.dig()
  35.   end
  36.   turtle.forward()
  37.   x = x + 1
  38. end
  39.  
  40. function mineZ()
  41.   while turtle.detect() == true do
  42.     turtle.dig()
  43.   end
  44.     turtle.forward()
  45.   z = z + 1
  46. end
  47.  
  48. function mineY()
  49.   turtle.turnRight()
  50.   while z > 1 do
  51.     data()
  52.     turtle.forward()
  53.     z = z - 1
  54.   end
  55.   turtle.turnRight()
  56.   if turtle.detectDown() == true then
  57.     turtle.digDown()
  58.   end
  59.   turtle.down()
  60.   y = y + 1
  61.   direction = "up"
  62.   x = 1
  63.   z = 1
  64. end
  65.  
  66. function finished()
  67.   while y > 1 do
  68.     turtle.up()
  69.     y = y - 1
  70.     data()
  71.   end
  72.   turtle.turnRight()
  73.   while z > 1 do
  74.     turtle.forward()
  75.     z = z - z
  76.     data()
  77.   end
  78.   running = "no"
  79.   data()
  80. end
  81.  
  82. function fuel()
  83.   while turtle.getFuelLevel() < 200 do
  84.     term.clear()
  85.     term.setCursorPos(1,1)
  86.     print("Refueling")
  87.     print("Ensure slot 1 has coal more than 5 coal")
  88.     sleep(5)
  89.     turtle.refuel(5)
  90.   end
  91. end
  92.  
  93. function data()
  94.   term.clear()
  95.   term.setCursorPos(1,1)
  96.   print("Running = ".. running)
  97.   print("X = ".. x)
  98.   print("Y = ".. y)
  99.   print("Z = ".. z)
  100.   print("fuel = ".. turtle.getFuelLevel())
  101. end
  102.  
  103. while running == "yes" do
  104.  
  105. data()
  106.  
  107.   fuel()
  108.   if y < Y then
  109.     if z < Z then
  110.       if x < X then
  111.         mineX()
  112.       else
  113.         if direction == "up" then
  114.           turtle.turnRight()
  115.           mineZ()
  116.           turtle.turnRight()
  117.           x = 1
  118.           direction = "down"
  119.         else
  120.           turtle.turnLeft()
  121.           mineZ()
  122.           turtle.turnLeft()
  123.           x = 1
  124.           direction = "up"
  125.         end
  126.       end
  127.     else
  128.       if (z == Z) and (x < X) then
  129.          mineX()
  130.       else
  131.         mineY()
  132.       end
  133.     end
  134.   else
  135.     if (y == Y) and (z < Z) and (x < X) then
  136.          mineX()
  137.     else
  138.       if (y == Y) and (z < Z) and (x == X) then
  139.         if direction == "up" then
  140.           turtle.turnRight()
  141.           mineZ()
  142.           turtle.turnRight()
  143.           x = 1
  144.           direction = "down"
  145.         else
  146.           turtle.turnLeft()
  147.           mineZ()
  148.           turtle.turnLeft()
  149.           x = 1
  150.           direction = "up"
  151.         end
  152.       else
  153.         if (y == Y) and (z == Z) and (x < X) then
  154.           mineX()
  155.         else
  156.           finished()
  157.         end
  158.       end
  159.     end
  160.   end
  161. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement