Advertisement
popatop15

Untitled

Oct 22nd, 2020
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.99 KB | None | 0 0
  1. local saplings = 1 -- the slot where the saplings are
  2. local log = 2
  3. local fuel = 3
  4.  
  5. function getSaplings(slot)
  6. turtle.select(slot)
  7. local need = 64 - turtle.getItemCount()
  8. if (need >= 20) then
  9. turtle.turnRight()
  10. turtle.turnRight()
  11. turtle.forward()
  12. turtle.forward()
  13. turtle.forward()
  14. turtle.turnRight()
  15. turtle.forward()
  16. turtle.forward()
  17. turtle.suck(need)
  18. turtle.turnRight()
  19. turtle.turnRight()
  20. turtle.forward()
  21. turtle.forward()
  22. turtle.turnLeft()
  23. turtle.forward()
  24. turtle.forward()
  25. turtle.forward()
  26. end
  27. end
  28.  
  29. function getFuel(slot)
  30. turtle.select(slot)
  31. local need = 64 - turtle.getItemCount()
  32. print("Need ",need," more fuel")
  33. if (need >= 20) then
  34. turtle.turnRight()
  35. turtle.turnRight()
  36. turtle.forward()
  37. turtle.forward()
  38. turtle.turnRight()
  39. turtle.forward()
  40. turtle.forward()
  41. turtle.suck(need)
  42. turtle.turnRight()
  43. turtle.turnRight()
  44. turtle.forward()
  45. turtle.forward()
  46. turtle.turnLeft()
  47. turtle.forward()
  48. turtle.forward()
  49. end
  50. end
  51.  
  52. while turtle.getItemCount(saplings) > 0 do -- while more saplings in inventory
  53. if turtle.getFuelLevel() < 30 then
  54. turtle.select(fuel)
  55. turtle.refuel(2)
  56. end
  57. getFuel(fuel)
  58. for i = 1, 7 do -- plant 8 saplings in a row
  59. turtle.turnLeft()
  60. turtle.select(log)
  61. if turtle.compare() then
  62. turtle.dig()
  63. end
  64. turtle.select(saplings)
  65. turtle.place()
  66. turtle.turnRight()
  67. turtle.forward()
  68. end
  69. -- turn around and line up for next pass
  70. turtle.turnRight()
  71. turtle.turnRight()
  72. for i = 1, 7 do
  73. turtle.forward()
  74. end
  75. turtle.turnRight()
  76. turtle.turnRight()
  77. getSaplings(saplings)
  78. sleep(30) -- sleep for 30 seconds to allow trees to grow
  79. end
  80.  
  81.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement