samh111

Mining Turtle

Nov 28th, 2020 (edited)
528
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function dig()
  2.     turtle.digUp()
  3.     turtle.digDown()
  4. end
  5.  
  6.  
  7. function forward()
  8.     turtle.dig()
  9.     checkGravel()
  10.     turtle.forward()
  11. end
  12.  
  13.  
  14. function turnRight()
  15.     turtle.turnRight()
  16.     if turtle.detect() then
  17.         turtle.dig()
  18.         checkGravel()
  19.     end
  20.     turtle.forward()
  21.     turtle.turnLeft()
  22. end
  23.  
  24.  
  25. function resetPos()
  26.     turtle.turnLeft()
  27.     turtle.forward()
  28.     turtle.forward()
  29.     turtle.turnRight()
  30.  end
  31.  
  32.  
  33. function checkGravel()
  34.     local sucess, data = turtle.inspect()
  35.     os.sleep(0.5)
  36.     while(sucess == true) do
  37.         if data.name == gravel then
  38.             turtle.dig()
  39.         end
  40.         sucess, data = turtle.inspect()
  41.     end
  42. end
  43.  
  44.  
  45. function main()
  46.     turtle.refuel()
  47.     print(turtle.getFuelLevel())
  48.  
  49.     print("How long in blocks do you want this mine to be?")
  50.     length = tonumber(read())
  51.     gravel = "minecraft:gravel"
  52.    
  53.     for i=1,length do
  54.         forward()
  55.         dig()
  56.         for i=0,1 do
  57.             turnRight()
  58.             dig()
  59.         end
  60.         resetPos()
  61.     end
  62. end
  63.  
  64.  
  65. main()
RAW Paste Data