Advertisement
Slinger0001

Mine

May 16th, 2025 (edited)
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.18 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 = 50
  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.  
  37.  
  38. local function ClearAbove()
  39.     if turtle.detectup() then
  40.         turtle.digup()
  41.     end
  42. end
  43.  
  44. local function Clearforward()
  45.     if turtle.detect() then
  46.         turtle.dig()
  47.     end
  48. end
  49.  
  50.  
  51.  
  52. -- Function to ensure the path is clear
  53. local function DigAll()
  54.     while turtle.getFuelLevel()>50 do
  55.             while distanceRight<10 do
  56.                 while distanceforward < distanceLimit  do
  57.                     ClearAbove()
  58.                     Left()
  59.                     Clearforward()
  60.                     Right()
  61.                     Right()
  62.                     Clearforward()
  63.                     Left()
  64.                     if forward == 1 then
  65.                         distanceforward = distanceforward+1
  66.                     else
  67.                         distanceforward = distanceforward-1
  68.                     end
  69.  
  70.                     if forward > 0  then
  71.                         forward = 0 --Backwards
  72.                         Right()
  73.                         Clearforward()
  74.                         distanceright = distanceright+1
  75.                         turtle.forward()
  76.                         Clearforward()
  77.                         distanceright = distanceright+1
  78.                         turtle.forward()
  79.                         Clearforward()
  80.                         distanceright = distanceright+1
  81.                         turtle.forward()
  82.                         Right()
  83.                     else
  84.                         forward = 1 --Forward
  85.                         Left()
  86.                         Clearforward()
  87.                         distanceright = distanceright+1
  88.                         turtle.forward()
  89.                         Clearforward()
  90.                         distanceright = distanceright+1
  91.                         turtle.forward()
  92.                         Clearforward()
  93.                         distanceright = distanceright+1
  94.                         turtle.forward()
  95.                         Left()
  96.                     end
  97.                 end
  98.             end    
  99.         if forward == 1 then
  100.             Left()
  101.             while distanceright>0 do
  102.                 turtle.forward()
  103.                 distanceright=distanceright-1
  104.             end
  105.         else
  106.             Right()
  107.             while distanceright>0 do
  108.             turtle.forward()
  109.             distanceright=distanceright-1
  110.             end
  111.             Left()
  112.             while distanceforward > 0 do
  113.                 turtle.forward()
  114.                 distanceforward = distanceforward-1
  115.             end
  116.         end
  117.     end
  118. end
  119. fuelcheck()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement