Advertisement
Guest User

treeFarm

a guest
May 22nd, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.17 KB | None | 0 0
  1. local xSize = 10
  2. local ySize = 10
  3.  
  4. local xPos = 0
  5. local yPos = 0
  6. local zPos = 0
  7.  
  8. local minFuel = 20
  9.  
  10. local forward = true
  11.  
  12. function refuel()
  13.   if turtle.getFuelLevel() < minFuel then
  14.     turtle.select(16)
  15.     turtle.refuel()
  16.   end
  17. end
  18.  
  19. function move()
  20.   if turtle.detect() then
  21.     return false
  22.   end
  23.  
  24.   turtle.forward()
  25.   if forward then
  26.     yPos = yPos + 1
  27.     if yPos > ySize then
  28.       turtle.turnRight()
  29.       turtle.forward()
  30.       turtle.forward()
  31.       turtle.turnRight()
  32.       xPos = xPos + 1
  33.       forward = not forward
  34.     end
  35.   else
  36.     yPos = yPos - 1  
  37.     if yPos <= 0 then
  38.       turtle.turnLeft()
  39.       turtle.forward()
  40.       turtle.forward()
  41.       turtle.turnLeft()
  42.       xPos = xPos + 1
  43.       foward = not forward
  44.     end
  45.   end
  46.  
  47.   if xPos > xSize then
  48.     if yPos == 0 then
  49.       turtle.turnLeft()
  50.     else
  51.       while yPos > 0 do
  52.         turtle.forward()
  53.         yPos = yPos - 1
  54.       end
  55.     end
  56.    
  57.     while xPos > 0 do
  58.       turtle.forward()
  59.       turtle.forward()
  60.       xPos = xPos - 1
  61.     end
  62.   end
  63. end
  64.  
  65. function dig()
  66.   turtle.dig()
  67. end
  68.  
  69. while true do
  70.   refuel()
  71.   print(move())
  72.   dig()
  73. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement