VicyX

ComputerCraft StripMining Turtle

Aug 27th, 2020 (edited)
2,044
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --Strip Mining Turtle Program v1.0
  2. local Steps = 0
  3. local Idle = true
  4. local Returning = false
  5.  
  6. function Dig()
  7.     turtle.dig()
  8.     turtle.digUp()
  9.     turtle.digDown()
  10. end
  11.  
  12. function Refuel()
  13.     for i=1,16 do
  14.         turtle.select(i)
  15.         if turtle.refuel(i) then
  16.             turtle.refuel(i)
  17.         end
  18.     end
  19.     turtle.select(1)
  20. end
  21.  
  22. function canContinue()
  23.     if turtle.getFuelLevel() > Steps then
  24.         return true
  25.     else
  26.         Refuel()
  27.         if turtle.getFuelLevel() > Steps then
  28.             return true
  29.         else
  30.             return false
  31.         end
  32.     end
  33.     return false
  34. end
  35.  
  36. function Return()
  37.     Returning = true
  38.     turtle.turnLeft()
  39.     turtle.turnLeft()
  40.     turtle.forward(Steps)
  41. end
  42.  
  43. while true do
  44.     if Idle == true then
  45.         while turtle.getFuelLevel < 5 do
  46.             Refuel()
  47.         end
  48.         Idle = false
  49.     else
  50.         if canContinue() then
  51.             if turtle.detect() == false then
  52.                 turtle.forward()
  53.                 Steps = Steps + 1
  54.             else
  55.                 Dig()
  56.             end
  57.         else
  58.             Return()
  59.             Idle = true
  60.         end
  61.     end
  62. end
RAW Paste Data