Advertisement
Guest User

CC Turtle Tree Farm

a guest
Mar 29th, 2020
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. function start()
  2.  
  3. moveFw(3)
  4.  
  5. turtle.turnRight()
  6. moveFw(1)
  7.  
  8. plantRow()
  9.  
  10. for i=2, 4 do
  11. if(i%2 == 0) then
  12. turtle.turnLeft()
  13. moveFw(4)
  14. turtle.turnLeft();
  15. else
  16. turtle.turnRight()
  17. moveFw(4)
  18. turtle.turnRight();
  19. end
  20. plantRow()
  21. end
  22. end
  23.  
  24. function plantRow()
  25. placeTree()
  26.  
  27. for i=1, 3 do
  28. moveFw(3)
  29. placeTree()
  30. end
  31. moveFw(1);
  32. end
  33.  
  34. function moveFw(distance)
  35. if distance ~= nil then
  36. distance = tonumber (distance) -- make it a number
  37. for i = 1, distance do
  38. turtle.forward()
  39. end
  40. else
  41. print ("Did not specify distance.")
  42. end
  43. end
  44. function placeTree()
  45. turtle.forward()
  46. turtle.select(3)
  47. turtle.place(Sapling)
  48. turtle.forward()
  49. turtle.select(4)
  50. turtle.place(Torch)
  51. end
  52.  
  53.  
  54. function refuel()
  55. turtle.select(16)
  56. turtle.refuel(20)
  57. if (checkFuel) then
  58. start()
  59. end
  60. end
  61.  
  62. function checkFuel()
  63. local fuel = turtle.getFuelLevel()
  64.  
  65. if (fuel < 10) then
  66. return false
  67. end
  68. return true
  69. end
  70.  
  71. refuel()
  72. start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement