Advertisement
GamingwithAtos

TreeFarm.lua

Dec 9th, 2019
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.78 KB | None | 0 0
  1. rednet.open("right")
  2. local tree = 0
  3. local height = 0
  4.  
  5. function PlantTree()
  6.  
  7. if turtle.getItemCount(1) == 0 then
  8. turtle.back()
  9. turtle.turnRight()
  10. turtle.select(1)
  11. turtle.suck()
  12. turtle.turnRight()
  13. ClearInv()
  14. end
  15.  
  16. print("PlantTree #" .. tree)
  17. turtle.select(1)
  18. turtle.place()
  19. BoneMeal()
  20. end
  21.  
  22. function BoneMeal()
  23. print("BoneMeal #" .. tree)
  24. turtle.select(2)
  25. while true do
  26. local bool, block = turtle.inspect()
  27. if block.name == "minecraft:log" then
  28. BreakTree()
  29. end
  30. turtle.place()
  31. end
  32. end
  33.  
  34. function BreakTree()
  35. print("BreakTree #" .. tree)
  36.  
  37. turtle.dig()
  38. turtle.forward()
  39.  
  40. while true do
  41. bool, block = turtle.inspectUp()
  42. if block.name == "minecraft:log" then
  43. turtle.digUp()
  44. turtle.up()
  45. height = height + 1
  46. end
  47.  
  48. if block.name ~= "minecraft:log" then
  49. while true do
  50. if height ~= 0 then
  51. turtle.down()
  52. height = height - 1
  53. end
  54. if height == 0 then
  55. turtle.back()
  56. tree = tree + 1
  57. sleep(20)
  58. PlantTree()
  59. end
  60. end
  61. end
  62. end
  63. end
  64.  
  65. function ClearInv()
  66.  
  67. turtle.select(3)
  68. turtle.drop()
  69. turtle.select(4)
  70. turtle.drop()
  71. turtle.select(5)
  72. turtle.drop()
  73. turtle.select(6)
  74. turtle.drop()
  75. turtle.select(7)
  76. turtle.drop()
  77. turtle.select(8)
  78. turtle.drop()
  79. turtle.select(9)
  80. turtle.drop()
  81. turtle.turnRight()
  82. turtle.turnRight()
  83. turtle.forward()
  84. PlantTree()
  85. end
  86.  
  87. PlantTree()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement