Advertisement
asweigart

chopper

Apr 20th, 2016
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.79 KB | None | 0 0
  1. -- assumes saplings in slots 1-4, bonemeal in slots 5-8, wood in 9-16
  2.  
  3.  
  4. local function selectSapling()
  5. turtle.select(1)
  6. if turtle.getItemCount() ~= 0 then
  7. return true
  8. end
  9. turtle.select(2)
  10. if turtle.getItemCount() ~= 0 then
  11. return true
  12. end
  13. turtle.select(3)
  14. if turtle.getItemCount() ~= 0 then
  15. return true
  16. end
  17. turtle.select(4)
  18. if turtle.getItemCount() ~= 0 then
  19. return true
  20. end
  21. return false
  22. end
  23.  
  24. local function selectBonemeal()
  25. local i
  26. for i = 5, 15 do
  27. turtle.select(i)
  28. if turtle.getItemCount() ~= 0 then
  29. return true
  30. end
  31. end
  32. return false
  33. end
  34.  
  35.  
  36. local i
  37. while true do
  38. if selectSapling() == false then
  39. print('Out of saplings.')
  40. end
  41.  
  42. turtle.place() -- plant sapling
  43.  
  44. -- place bonemeal until a tree grows
  45. while true do
  46. if selectBonemeal() == false then
  47. print('Out of bonemeal.')
  48. end
  49.  
  50. if turtle.place() == false then
  51. break -- tree has grown
  52. end
  53. end
  54.  
  55. -- wait until a tree has grown
  56. while true do
  57. success, itemData = turtle.inspect()
  58. if itemData ~= nil and itemData['name'] == 'minecraft:sapling' then
  59. print('Waiting for sapling to grow...')
  60. os.sleep(5)
  61. else
  62. break
  63. end
  64. end
  65.  
  66. turtle.select(16)
  67. turtle.dig()
  68. turtle.forward()
  69. while turtle.compareUp() do
  70. turtle.digUp()
  71. turtle.up()
  72. end
  73. -- move back down
  74. while not turtle.detectDown() do
  75. turtle.down()
  76. end
  77.  
  78. -- pick up any saplings & apples on the ground
  79. turtle.select(14)
  80. for i = 1, 4 do
  81. turtle.suck()
  82. turtle.turnLeft()
  83. end
  84.  
  85. -- move to chest
  86. turtle.back()
  87. turtle.turnLeft()
  88. turtle.turnLeft()
  89. for i = 14, 16 do
  90. turtle.select(i)
  91. turtle.drop()
  92. end
  93. turtle.turnLeft()
  94. turtle.turnLeft()
  95. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement