Advertisement
saljun

tree plant grow

Apr 23rd, 2014
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.71 KB | None | 0 0
  1. local function consolidate()
  2. local i = 3
  3. while (i < 16) do
  4. i = i + 1
  5. turtle.select(i)
  6. if (turtle.compareTo(1)) then
  7. turtle.transferTo(1)
  8. end
  9. if (turtle.compareTo(2)) then
  10. turtle.transferTo(2)
  11. end
  12. if (turtle.compareTo(3)) then
  13. turtle.transferTo(3)
  14. end
  15. end
  16. end
  17. local function checkItem(slot, count)
  18. if (turtle.getItemCount(slot) > count) then
  19. return true
  20. end
  21. return false
  22. end
  23. local function checkFuel()
  24. return checkItem(1, 1)
  25. end
  26. local function checkSaplings()
  27. return checkItem(2, 1)
  28. end
  29. local function checkBonemeal()
  30. return checkItem(3, 1)
  31. end
  32.  
  33. local function refillBonemeal()
  34. if (verifyPos()) then
  35. turtle.turnRight()
  36. turtle.suck()
  37. turtle.turnLeft()
  38. end
  39. end
  40. local function refillSaplings()
  41. if (verifyPos()) then
  42. turtle.turnRight()
  43. turtle.turnRight()
  44. turtle.suck()
  45. turtle.turnRight()
  46. turtle.turnRight()
  47. end
  48. end
  49. local function refillCoal()
  50. if (verifyPos()) then
  51. turtle.turnLeft()
  52. turtle.suck()
  53. turtle.turnRight()
  54. end
  55. end
  56.  
  57. local function plantSaplings()
  58. turtle.select(2)
  59. turtle.place()
  60. end
  61.  
  62. local function growTree()
  63. turtle.select(4)
  64. while (turtle.compare() == false) do
  65. if (checkBonemeal() == false) then
  66. break
  67. end
  68. turtle.select(3)
  69. turtle.place()
  70. turtle.select(4)
  71. end
  72. end
  73.  
  74. while (turtle.getFuelLevel() > 100) do
  75. consolidate()
  76. if (checkFuel() == false) then
  77. refillCoal()
  78. consolidate()
  79. if (checkFuel() == false) then
  80. break
  81. end
  82. end
  83. if (checkSaplings() == false) then
  84. refillSaplings()
  85. consolidate()
  86. if (checkSaplings() == false) then
  87. break
  88. end
  89. end
  90. if (checkBonemeal() == false) then
  91. refillBonemeal()
  92. consolidate()
  93. if (checkBonemeal() == false) then
  94. break
  95. end
  96. end
  97. plantSaplings()
  98. growTree()
  99. if (turtle.getFuelLevel() < 100) then
  100. turtle.select(1)
  101. turtle.refuel(2)
  102. end
  103. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement