Advertisement
ZeroTwoThePistol

Untitled

May 22nd, 2021
915
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 7.73 KB | None | 0 0
  1.  
  2. --How to use:
  3. --Place a chest to the left of the turtle for fuel and a chest behind it for a place to drop off items.
  4. --"Quarry or bore?" Type "quarry" for a quarry or "bore" to mine a single layer. Make sure you type in all lowercase.
  5. --"Rows" If looking from above, this is how many blocks it will mine in the 'y' axis.
  6. --"Columns" If looking from above, this is how many blocks it will mine in the 'x' axis.
  7. --"Current 'y' level?" The 'y' level of the turtle.
  8. --"Toss garbage blocks?" Type "yes" to toss out stone, gravel, dirt, etc. Make sure you type in all lowercase.
  9.  
  10. term.clear()
  11. term.setCursorPos(1,1)
  12. io.write("Quarry or bore? ")
  13. quarrybore = io.read()
  14. term.clear()
  15. term.setCursorPos(1,1)
  16. io.write("Rows: ")
  17. rows = io.read()
  18. io.write("Columns: ")
  19. columns = io.read()
  20. iniY = 2
  21. if quarrybore == "quarry" then
  22.     term.clear()
  23.     term.setCursorPos(1,1)
  24.     io.write("Current 'y' level: ")
  25.     iniY = io.read()
  26. end
  27. term.clear()
  28. term.setCursorPos(1,1)
  29. io.write("Toss garbage blocks? ")
  30. tossGarbage = io.read()
  31. term.clear()
  32. term.setCursorPos(1,1)
  33.  
  34. posX = 0
  35. posY = 0
  36. posZ = 0
  37.  
  38. rotation = 0
  39.  
  40. fullSlots = 0
  41.  
  42. function info()
  43.     term.clear()
  44.     term.setCursorPos(1,1)
  45.     print("---------------------------------------")
  46.     print("Mining size: " .. rows .. " by " .. columns)
  47. --  print("Total distance: " .. posX + posY + posZ)
  48. --  print("X: " .. posX)
  49. --  print("Y: " .. posY)
  50. --  print("Z: " .. posZ)
  51. --  print("Orientation: " .. rotation)
  52.     if tossGarbage == "yes" then
  53.         print("Toss garbage: Yes")
  54.     else
  55.         print("Toss garbage: No")
  56.     end
  57.     print("")
  58.     print("Fuel level: " .. turtle.getFuelLevel())
  59. end
  60.  
  61. function rotate()
  62.     if rotation == 0 then
  63.         turtle.turnLeft()
  64.     elseif rotation == 1 then
  65.         turtle.turnLeft()
  66.         turtle.turnLeft()
  67.     elseif rotation == 2 then
  68.         turtle.turnRight()
  69.     end
  70. end
  71.  
  72. function recover()
  73.     rotate()
  74.     local step = 0
  75.     for step = posY - 1, 0, -1 do
  76.         turtle.up()
  77.     end
  78.     for step = posX - 1, 0, -1 do
  79.         turtle.forward()
  80.     end
  81.     turtle.turnLeft()
  82.     for step = posZ - 1, 0, -1 do
  83.         turtle.forward()
  84.     end
  85. end
  86.  
  87. function resume()
  88.     turtle.turnLeft()
  89.     turtle.turnLeft()
  90.     local step = 0
  91.     for step = 0, posZ - 1, 1 do
  92.         turtle.forward()
  93.     end
  94.     turtle.turnRight()
  95.     for step = 0, posX - 1, 1 do
  96.         turtle.forward()
  97.     end
  98.     for step = 0, posY - 1, 1 do
  99.         turtle.down()
  100.     end
  101.     if rotation == 0 then
  102.         turtle.turnLeft()
  103.     elseif rotation == 2 then
  104.         turtle.turnRight()
  105.     elseif rotation == 3 then
  106.         turtle.turnRight()
  107.         turtle.turnRight()
  108.     end
  109. end
  110.  
  111. function checkFuel()
  112.     turtle.select(1)
  113.     turtle.refuel()
  114.     if turtle.getFuelLevel() <= posX + posY + posZ + 1 then
  115.         refill = 1
  116.         empty()
  117.         refill = 0
  118.     end
  119. end
  120.  
  121. function empty()
  122.     recover()
  123.     if quarrybore == "bore" then
  124.         turtle.down()
  125.     end
  126.     local search = 0
  127.     for search = 16, 1, -1 do
  128.         turtle.select(search)
  129.         turtle.drop()
  130.     end
  131.     if refill == 1 then
  132.         turtle.turnRight()
  133.         while turtle.getFuelLevel() <= posX + posY + posZ + 1 do
  134.             if turtle.suck() == true then
  135.                 turtle.suck()
  136.                 turtle.select(1)
  137.                 turtle.refuel()
  138.             elseif turtle.suck() == false then
  139.                 turtle.select(1)
  140.                 turtle.refuel()
  141.                 term.clear()
  142.                 term.setCursorPos(1,1)
  143.                 io.write("Please add more fuel to slot '1' or fuel chest.")
  144.             end
  145.         end
  146.         turtle.turnLeft()
  147.         resume()
  148.     end
  149.     if done ~= 1 then
  150.         if quarrybore == "bore" then
  151.             turtle.up()
  152.         end
  153.         resume()
  154.     end
  155. end
  156.  
  157. function checkFull()
  158.     fullSlots = 0
  159.     local search = 0
  160.     for search = 16, 1, -1 do
  161.         turtle.select(search)
  162.         if turtle.getItemCount() > 0 then
  163.             if tossGarbage == "yes" then
  164.                 if turtle.getItemDetail().name == "minecraft:cobblestone" then
  165.                     turtle.drop()
  166.                 elseif turtle.getItemDetail().name == "minecraft:stone" then
  167.                     turtle.drop()
  168.                 elseif turtle.getItemDetail().name == "minecraft:dirt" then
  169.                     turtle.drop()
  170.                 elseif turtle.getItemDetail().name == "minecraft:gravel" then
  171.                     turtle.drop()
  172.                 elseif turtle.getItemDetail().name == "chisel:marble2" then
  173.                     turtle.drop()
  174.                 elseif turtle.getItemDetail().name == "chisel:limestone2" then
  175.                     turtle.drop()
  176.                 elseif turtle.getItemDetail().name == "minecraft:netherrack" then
  177.                     turtle.drop()
  178.                 elseif turtle.getItemDetail().name == "natura:nether_tainted_soil" then
  179.                     turtle.drop()
  180.                 end
  181.             end
  182.         end
  183.         if turtle.getItemCount() > 0 then
  184.             fullSlots = fullSlots + 1
  185.         end
  186.     end
  187.     if fullSlots == 16 then
  188.         empty()
  189.     end
  190. end
  191.  
  192. function nextRow()
  193.     if turn == 0 then
  194.         turtle.turnRight()
  195.         rotation = 1
  196.         digStraight()
  197.         turtle.turnRight()
  198.         rotation = 2
  199.         turn = 1
  200.     elseif turn == 1 then
  201.         turtle.turnLeft()
  202.         rotation = 1
  203.         digStraight()
  204.         turtle.turnLeft()
  205.         rotation = 0
  206.         turn = 0
  207.     elseif turn == 2 then
  208.         turtle.turnRight()
  209.         rotation = 3
  210.         digStraight()
  211.         turtle.turnRight()
  212.         rotation = 0
  213.         turn = 3
  214.     elseif turn == 3 then
  215.         turtle.turnLeft()
  216.         rotation = 3
  217.         digStraight()
  218.         turtle.turnLeft()
  219.         rotation = 2
  220.         turn = 2
  221.     end
  222. end
  223.  
  224. function digDown()
  225.     checkFuel()
  226.     local step = 0
  227.     for step = 2, 0, -1 do
  228.         turtle.digDown()
  229.         if turtle.down() == true then
  230.             posY = posY + 1
  231.         end
  232.         info()
  233.     end
  234. end
  235.  
  236. function digStraight()
  237.     checkFuel()
  238.     turtle.digDown()
  239.     turtle.dig()
  240.     turtle.dig()
  241.     turtle.forward()
  242.     if rotation == 0 then
  243.         posZ = posZ + 1
  244.     elseif rotation == 1 then
  245.         posX = posX + 1
  246.     elseif rotation == 2 then
  247.         posZ = posZ - 1
  248.     elseif rotation == 3 then
  249.         posX = posX - 1
  250.     end
  251.     turtle.digUp()
  252.     info()
  253. end
  254.  
  255. function quarry()
  256.     turn = 0
  257.     done = 0
  258.     iniY = tonumber (iniY)
  259.     checkFuel()
  260.     turtle.digUp()
  261.     turtle.up()
  262.     posY = posY - 1
  263.     while posY < iniY - 2 do
  264.         if quarrybore == "quarry" then
  265.             digDown()
  266.         end
  267.         for c = columns, 1, -1 do
  268.             for r = rows, 2, -1 do
  269.                 digStraight()
  270.             end
  271.             checkFull()
  272.             if c == 1 then
  273.                 turtle.turnRight()
  274.                 turtle.turnRight()
  275.                 if rotation == 0 then
  276.                     rotation = 2
  277.                 elseif rotation == 2 then
  278.                     rotation = 0
  279.                 end
  280.                 if turn == 0 then
  281.                     turn = 2
  282.                 elseif turn == 1 then
  283.                     turn = 3
  284.                 elseif turn == 2 then
  285.                     turn = 0
  286.                 elseif turn == 3 then
  287.                     turn = 1
  288.                 end
  289.             elseif c > 1 then
  290.                 nextRow()
  291.             end
  292.         end
  293.         if quarrybore == "bore" then
  294.             posY = posY + 1
  295.         end
  296.     end
  297.     turtle.digDown()
  298.     done = 1
  299.     empty()
  300.     term.clear()
  301.     term.setCursorPos(1,1)
  302.     print("Give me more Commands Master~")
  303.     print("---------------------------------------")
  304. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement