Advertisement
Slinger0001

Mine

May 16th, 2025 (edited)
418
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.13 KB | None | 0 0
  1. -- Simple Mining Program
  2.  
  3.  
  4. -- Set the number of blocks to mine
  5. local distanceforward = 0
  6. local forward = 1 --Forward Facing
  7. local distanceBackward = 0
  8. local distanceLeft = 0
  9. local distanceRight = 0
  10. local distanceLimit = 10
  11. local FuelAmount = 0
  12.  
  13.  
  14. -- Check Fuel Level
  15. --local function fuelcheck()
  16. --    FuelAmount = turtle.getFuelLevel()
  17. --    print("Fuel Level " .. FuelAmount)
  18. --end
  19.  
  20. -- Fuel Up
  21. local function Fuel()
  22.     turtle.select(1)
  23.     turtle.refuel(64)
  24.     turtle.select(2)
  25.     turtle.refuel(64)
  26.     turtle.select(1)
  27. end
  28.  
  29. local function Left()
  30.     turtle.turnLeft()
  31. end
  32.  
  33. local function Right()
  34.     turtle.turnRight()
  35. end
  36. local function Up()
  37.     turtle.up()
  38. end
  39. local function Down()
  40.     turtle.down()
  41. end
  42.  
  43.  
  44.  
  45. local function ClearAbove()
  46.     if turtle.detectUp() then
  47.         turtle.digUp()
  48.     end
  49. end
  50.  
  51. local function Clearforward()
  52.     if turtle.detect() then
  53.         turtle.dig()
  54.     end
  55. end
  56.  
  57.  
  58.  
  59. -- Function to ensure the path is clear
  60. local function DigAll()
  61.     while turtle.getFuelLevel()>50 do
  62.             while distanceRight<10 do
  63.                 while distanceforward < distanceLimit  do
  64.                     Left()
  65.                     Clearforward()
  66.                     Right()
  67.                     Clearforward()
  68.                     Right()
  69.                     Clearforward()
  70.                     Up()
  71.                     Clearforward()
  72.                     Left()
  73.                     Left()
  74.                     Clearforward()
  75.                     Right()
  76.                     Clearforward()
  77.                     Down()
  78.                     if forward == 1 then
  79.                         Clearforward()
  80.                         turtle.forward()
  81.                         distanceforward = distanceforward+1
  82.                     else
  83.                         Clearforward()
  84.                         turtle.forward()
  85.                         distanceforward = distanceforward-1
  86.                     end
  87.  
  88.                    
  89.                 end
  90.                 if forward > 0  then
  91.                     forward = 0 --Backwards
  92.                     Right()
  93.                     Clearforward()
  94.                     ClearAbove()
  95.                     distanceRight = distanceRight+1
  96.                     turtle.forward()
  97.                     Clearforward()
  98.                     ClearAbove()
  99.                     distanceRight = distanceRight+1
  100.                     turtle.forward()
  101.                     Clearforward()
  102.                     ClearAbove()
  103.                     distanceRight = distanceRight+1
  104.                     turtle.forward()
  105.                     Right()
  106.                     Clearforward()
  107.                     ClearAbove()
  108.                     turtle.forward()
  109.                     ClearAbove()
  110.                     distanceforward = distanceforward-1
  111.                 else
  112.                     forward = 1 --Forward
  113.                     Left()
  114.                     Clearforward()
  115.                     ClearAbove()
  116.                     distanceRight = distanceRight+1
  117.                     turtle.forward()
  118.                     Clearforward()
  119.                     ClearAbove()
  120.                     distanceRight = distanceRight+1
  121.                     turtle.forward()
  122.                     Clearforward()
  123.                     distanceRight = distanceRight+1
  124.                     turtle.forward()
  125.                     ClearAbove()
  126.                     Left()
  127.                     Clearforward()
  128.                     ClearAbove()
  129.                     turtle.forward()
  130.                     distanceforward = distanceforward+1
  131.                 end
  132.             end    
  133.         if forward == 1 then
  134.             Left()
  135.             while distanceRight>0 do
  136.                 turtle.forward()
  137.                 distanceRight=distanceRight-1
  138.             end
  139.         else
  140.             Right()
  141.             while distanceRight>0 do
  142.             turtle.forward()
  143.             distanceRight=distanceRight-1
  144.             end
  145.             Left()
  146.             while distanceforward > 0 do
  147.                 turtle.forward()
  148.                 distanceforward = distanceforward-1
  149.             end
  150.         end
  151.     end
  152. end
  153.  
  154. Fuel()
  155. DigAll()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement