Advertisement
M0n5t3r

treeFarm

Jun 7th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.72 KB | None | 0 0
  1. local up = 0
  2. local right_movement = 0
  3. local last = "left"
  4.  
  5. function getTree()
  6. turtle.dig()
  7. turtle.forward()
  8.  
  9. while turtle.detectUp() do
  10. turtle.digUp()
  11. turtle.up()
  12. up = up + 1
  13. end
  14. repeat
  15. turtle.down()
  16. up = up - 1
  17. until up == 0
  18. turtle.digDown()
  19. turtle.select(1)
  20. turtle.placeDown()
  21. end
  22.  
  23. function back(amount)
  24. local _back = 0
  25. repeat
  26. turtle.back()
  27. _back = _back + 1
  28. until _back == amount
  29. end
  30. function forward(amount)
  31. local _forward = 0
  32. repeat
  33. turtle.forward()
  34. _forward = _forward + 1
  35. until _forward == amount
  36. end
  37.  
  38. function start()
  39. turtle.turnLeft()
  40. turtle.forward()
  41. for q=4,16 do
  42. turtle.select(q)
  43. turtle.dropDown()
  44. end
  45. back(2)
  46. turtle.select(1)
  47. turtle.suckDown(25)
  48.  
  49. back(3)
  50.  
  51. turtle.select(2)
  52. turtle.suckDown(25)
  53.  
  54. back(3)
  55.  
  56. turtle.select(3)
  57. turtle.suckDown(25)
  58.  
  59. forward(7)
  60. turtle.turnRight()
  61. end
  62.  
  63. function walk()
  64. local forward = 0
  65. repeat
  66. if turtle.forward() == false then
  67. getTree()
  68. else
  69. forward = forward + 1
  70. end
  71. until forward == 21
  72. end
  73.  
  74. function moveRight()
  75. turtle.turnRight()
  76. forward(3)
  77. turtle.turnRight()
  78. right_movement = right_movement + 1
  79. last = "right"
  80. end
  81. function moveLeft()
  82. turtle.turnLeft()
  83. forward(3)
  84. turtle.turnLeft()
  85. right_movement = right_movement + 1
  86. last = "left"
  87.  
  88. end
  89.  
  90. start()
  91. turtle.up()
  92. repeat
  93. walk()
  94. if last == "left" then
  95. moveRight()
  96. elseif last == "right" then
  97. moveLeft()
  98. end
  99. until right_movement == 5
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement