Advertisement
Guest User

Clearing Turtle

a guest
Oct 16th, 2018
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.59 KB | None | 0 0
  1. --DYNAMIC GLOBAL VARS INPUT
  2.  
  3. print("Place the turtle facing on the edge of the clearing zone, facing west to east.")
  4. print("Select the number of lines you wish to have mined.")
  5. lines = tonumber(read())
  6. print("You selected:", lines)
  7. os.sleep(2)
  8. term.clear()
  9.  
  10. print("Select the length of lines you wish to have mined.")
  11. lineLength = tonumber(read())
  12. print("You selected:", lineLength)
  13. os.sleep(2)
  14. term.clear()
  15.  
  16. --FIXED GLOBAL VARS
  17.  
  18. distance = 0
  19. lineDist = 1
  20. orrentation = 0
  21.  
  22. function Refuel()
  23.     local fuelLvl = turtle.getFuelLevel()
  24.  
  25.     turtle.getFuelLevel()
  26.     if turtle.getFuelLevel() then
  27.         turtle.select(1)
  28.         turtle.getItemCount()
  29.     end
  30. end
  31.  
  32. function Turn()
  33.     local leftTurn = turtle.turnLeft()
  34.     local rightTurn = turtle.turnRight()
  35.  
  36.     if lineDist == lineLength then    --LINE PROGRESS CHECK
  37.         lines = lines + 1
  38.         if (lines % 2 == 0) then      --LINE VAR EVEN CHECK
  39.             turtle.turnLeft()
  40.             turtle.dig()
  41.             turtle.forward()
  42.             turtle.turnLeft()
  43.         elseif (lines % 2 ~= 0) then  --LINE VAR ODD CHECK
  44.             turtle.turnRight()
  45.             turtle.dig()
  46.             turtle.forward()
  47.             turtle.turnRight()
  48.         end
  49.         lineDist = lineDist - (lineLength - 1)  --LINE VAR RESET
  50.     end
  51.  
  52. end
  53.  
  54. function Dig()
  55.     local attemptForward = turtle.forward()
  56.  
  57.     for i=0,lineLength do
  58.         turtle.select(1)
  59.         turtle.dig()
  60.         turtle.forward()
  61.         if attemptForward == true then
  62.             distance = distance + 1
  63.         elseif attemptForward == false then
  64.             Dig()
  65.         elseif lineDist == lineLength then
  66.             Turn()
  67.         end
  68.     end
  69. end
  70.  
  71. function Quarry()
  72.     for i=0,lines do
  73.         Refuel()
  74.         Dig()
  75.     end
  76. end
  77.  
  78. function Return()
  79.    
  80. end
  81.  
  82. Quarry()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement