Advertisement
PerryExtra

Untitled

Apr 30th, 2022 (edited)
273
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 8.05 KB | None | 0 0
  1. --INSTRUCTIONS--
  2. --When placing the turtle down . . .
  3. -- 1) Fuel chest should be on the left side of the turtle.
  4. -- 2) Depo chest should be behind the turtle.
  5. -- 3) Then run the program and let it go.
  6. -- X) Don't forget to chunk load the area the turtle will be in. Be it with a player or other options.
  7.  
  8. --TO DO LIST--
  9. --Add an if-else for different size areas (in both length and row).
  10. --Turn the travel functions into actual functions (if-for).
  11.  
  12.  
  13. --Variables--
  14. local definedLength = 16
  15. local definedRow = 16
  16.  
  17. local length = 1
  18. local row = 1
  19. local depth = 1
  20.  
  21.  
  22. --Get initial fuel setup--
  23. turtle.refuel()
  24. turtle.turnLeft()
  25. turtle.select(1)
  26. turtle.suck()
  27. turtle.refuel()
  28. turtle.turnRight()
  29.  
  30.  
  31. --Start Mining Loop--
  32. print("Start quarry.")
  33. while (true) do --Main quarry script--
  34.  
  35.  
  36.     --REFUEL AND INVENTORY DUMP SEQUENCE--
  37.     if ( (turtle.getFuelLevel() <= length + row + depth) or (turtle.getItemCount(16) > 0) ) then --Check fuel level OR Check inventory level--
  38.  
  39.         --RETURN TO CHEST SUB-SEQUENCE--
  40.         if (depth > 1) then --Return in height to the chest--
  41.             for i=depth,1,-1 do
  42.                 turtle.up()
  43.             end
  44.         end
  45.  
  46.         if (depth % 2 == 1) then    --Return to the chest in row and length based of position (It will choose one of 4 configurations)--
  47.  
  48.             if (row % 2 == 1) then
  49.                 --CONFIGURATION 1--
  50.                 turtle.turnLeft()
  51.                 if (row > 1) then
  52.                     for i=row,1,-1 do
  53.                         turtle.forward()
  54.                     end
  55.                 end
  56.                 turtle.turnLeft()
  57.                 if (length > 1) then
  58.                     for i=length,1,-1 do
  59.                         turtle.forward()
  60.                     end
  61.                 end
  62.                 --###############--
  63.             else
  64.                 --CONFIGURATION 2--
  65.                 turtle.turnRight()
  66.                 if (row > 1) then
  67.                     for i=row,1,-1 do
  68.                         turtle.forward()
  69.                     end
  70.                 end
  71.                 turtle.turnLeft()
  72.                 if (definedLength - length > 1) then
  73.                     for i=definedLength - length,1,-1 do
  74.                         turtle.forward()
  75.                     end
  76.                 end
  77.                 --###############--
  78.             end
  79.  
  80.         else
  81.  
  82.             if (row % 2 == 1) then
  83.                 --CONFIGURATION 3--
  84.                 turtle.turnLeft()
  85.                 if (definedRow - row > 1) then
  86.                     for i=definedRow - row,1,-1 do
  87.                         turtle.forward()
  88.                     end
  89.                 end
  90.                 turtle.turnLeft()
  91.                 if (length > 1) then
  92.                     for i=length,1,-1 do
  93.                         turtle.forward()
  94.                     end
  95.                 end
  96.                 --###############--
  97.             else
  98.                 --CONFIGURATION 4--
  99.                 turtle.turnRight()
  100.                 if (definedRow - row > 1) then
  101.                     for i=definedRow - row,1,-1 do
  102.                         turtle.forward()
  103.                     end
  104.                 end
  105.                 turtle.turnLeft()
  106.                 if (definedLength - length > 1) then
  107.                     for i=definedLength - length,1,-1 do
  108.                         turtle.forward()
  109.                     end
  110.                 end
  111.                 --###############--
  112.             end
  113.  
  114.         end
  115.  
  116.         --ITEM OFFLOAD AND REFUELLING SUB-SEQUENCE--
  117.         for i=1,16,1 do --Drop all inventory into chest but also consume anything that can be used as fuel--
  118.             turtle.select(i)
  119.             turtle.refuel()
  120.             turtle.drop()
  121.         end
  122.         turtle.turnRight() --Refuel from fuel chest--
  123.         turtle.select(1)
  124.         turtle.suck()
  125.         turtle.refuel()
  126.         turtle.turnRight()
  127.  
  128.  
  129.         ----RETURN TO CURRENT MINING LOCATION SUB-SEQUENCE--
  130.         if (depth % 2 == 1) then    --Return to the current mining location in row and length based of position (It will choose one of 4 configurations)--
  131.  
  132.             if (row % 2 == 1) then
  133.                 --CONFIGURATION 1--
  134.                 if (length > 1) then
  135.                     for i=length,1,-1 do
  136.                         turtle.forward()
  137.                     end
  138.                 end
  139.                 turtle.turnRight()
  140.                 if (row > 1) then
  141.                     for i=row,1,-1 do
  142.                         turtle.forward()
  143.                     end
  144.                 end
  145.                 turtle.turnLeft()
  146.                 --###############--
  147.             else
  148.                 --CONFIGURATION 2--
  149.                 if (definedLength - length > 1) then
  150.                     for i=definedLength - length,1,-1 do
  151.                         turtle.forward()
  152.                     end
  153.                 end
  154.                 turtle.turnRight()
  155.                 if (row > 1) then
  156.                     for i=row,1,-1 do
  157.                         turtle.forward()
  158.                     end
  159.                 end
  160.                 turtle.turnRight()
  161.                
  162.                 --###############--
  163.             end
  164.  
  165.         else
  166.  
  167.             if (row % 2 == 1) then
  168.                 --CONFIGURATION 3--
  169.                 if (definedLength - length > 1) then
  170.                     for i=definedLength - length,1,-1 do
  171.                         turtle.forward()
  172.                     end
  173.                 end
  174.                 turtle.turnRight()
  175.                 if (definedRow - row > 1) then
  176.                     for i=definedRow - row,1,-1 do
  177.                         turtle.forward()
  178.                     end
  179.                 end
  180.                 turtle.turnLeft()
  181.                
  182.                 --###############--
  183.             else
  184.                 --CONFIGURATION 4--
  185.                 if (length > 1) then
  186.                     for i=length,1,-1 do
  187.                         turtle.forward()
  188.                     end
  189.                 end
  190.                 turtle.turnRight()
  191.                 if (definedRow - row > 1) then
  192.                     for i=definedRow - row,1,-1 do
  193.                         turtle.forward()
  194.                     end
  195.                 end
  196.                 turtle.turnRight()
  197.                
  198.                 --###############--
  199.             end
  200.  
  201.         end
  202.        
  203.         if (depth > 1) then --Return in height to the chest--
  204.             for i=depth,1,-1 do
  205.                 turtle.down()
  206.             end
  207.         end
  208.  
  209.     end
  210.  
  211.  
  212.     --QUARRYING SEQUENCE--
  213.     if (length < definedLength) then --Go forward--
  214.         turtle.dig()
  215.         turtle.forward()
  216.         length = length + 1
  217.     else
  218.         if (row < definedRow) then   --Move to next row--
  219.             if (row % 2 == 1) then   --Check which way to turn (Zig Zag pattern)--
  220.                 if (depth % 2 == 1) then    --Invert if it goes down one level (Diagonal starting position from original starting position)--
  221.                     turtle.turnRight()
  222.                     turtle.dig()
  223.                     turtle.forward()
  224.                     turtle.turnRight()
  225.                 else
  226.                     turtle.turnLeft()
  227.                     turtle.dig()
  228.                     turtle.forward()
  229.                     turtle.turnLeft()
  230.                 end
  231.             else
  232.                 if (depth % 2 == 1) then    --Invert if it goes down one level (Diagonal starting position from original starting position)--
  233.                     turtle.turnLeft()
  234.                     turtle.dig()
  235.                     turtle.forward()
  236.                     turtle.turnLeft()
  237.                 else
  238.                     turtle.turnRight()
  239.                     turtle.dig()
  240.                     turtle.forward()
  241.                     turtle.turnRight()
  242.                 end
  243.             end
  244.             length = 1
  245.             row = row + 1
  246.         else    --Go down a level--
  247.             turtle.turnRight()
  248.             turtle.turnRight()
  249.             turtle.digDown()
  250.             turtle.down()
  251.             length = 1
  252.             row = 1
  253.             depth = depth + 1
  254.         end
  255.     end
  256. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement