Drakaxx

Farm Tree

Apr 17th, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.29 KB | None | 0 0
  1. function putSaplingInRightPlaceIfNeeded()
  2. turtle.select(1)
  3. local dataPlaceOne = turtle.getItemDetail()
  4. if dataPlaceOne then
  5. if dataPlaceOne.name ~= 'minecraft:sapling' then
  6. getEmptySlot()
  7. turtle.select(1)
  8. turtle.transferTo(emptySlot)
  9. for h=2,15 do
  10. turtle.select(h)
  11. local dataPlaceX = turtle.getItemDetail()
  12. if dataPlaceX then
  13. if dataPlaceX.name == 'minecraft:sapling' then
  14. turtle.transferTo(1)
  15. h = 15
  16. end
  17. end
  18. end
  19. end
  20. end
  21. end
  22.  
  23. function getEmptySlot()
  24. emptySlot = 0
  25. for g=2,15 do
  26. turtle.select(g)
  27. local dataPresent = turtle.getItemDetail()
  28. if dataPresent then
  29. else
  30. emptySlot = g
  31. g = 15
  32. end
  33. end
  34. end
  35.  
  36. function xFuel()
  37. turtle.select(16)
  38. turtle.refuel()
  39. turtle.select(1)
  40. end
  41.  
  42. function xGetCoalIfNeeded()
  43. if turtle.getFuelLevel() <= 1000 then
  44. turtle.select(16)
  45. turtle.turnLeft()
  46. turtle.suck(13)
  47. turtle.turnRight()
  48. xFuel()
  49. end
  50. turtle.select(1)
  51. end
  52.  
  53. function xDigIfNeeded()
  54. local success, data = turtle.inspect()
  55. if success then
  56. if data.name == 'minecraft:log' then
  57. turtle.dig()
  58. turtle.suck()
  59. turtle.select(1)
  60. turtle.place()
  61. end
  62. else
  63. turtle.select(1)
  64. turtle.place()
  65. end
  66. end
  67.  
  68. function xSuck()
  69. local success, data = turtle.inspect()
  70. if success then
  71. if data.name ~= 'minecraft:chest' then
  72. turtle.suck()
  73. end
  74. else
  75. turtle.suck()
  76. end
  77. end
  78.  
  79. function xCheckAround()
  80. putSaplingInRightPlaceIfNeeded()
  81. xDigIfNeeded()
  82. xSuck()
  83. turtle.turnLeft()
  84. xDigIfNeeded()
  85. xSuck()
  86. turtle.turnRight()
  87. turtle.turnRight()
  88. xDigIfNeeded()
  89. xSuck()
  90. turtle.turnLeft()
  91. end
  92.  
  93. function xDropToChest()
  94. for n=2,15 do
  95. turtle.select(n)
  96. local dataToDropDown = turtle.getItemDetail()
  97. if dataToDropDown then
  98. if dataToDropDown.name == 'minecraft:log' then
  99. turtle.dropDown()
  100. end
  101. end
  102.  
  103. end
  104. turtle.select(1)
  105. end
  106.  
  107. function xGetSaplingIfNeeded()
  108. if turtle.getItemCount(1) < 63 then
  109. turtle.select(1)
  110. turtle.turnRight()
  111. turtle.suck()
  112. turtle.turnLeft()
  113. end
  114. end
  115.  
  116. function xForward()
  117. local successs, dataa = turtle.inspectDown()
  118. if successs then
  119. if dataa.name == 'minecraft:netherrack' then
  120. turtle.turnRight()
  121. end
  122. if dataa.name == 'minecraft:log' then
  123. turtle.turnLeft()
  124. end
  125. if dataa.name == 'minecraft:chest' then
  126. xThrow()
  127. xGetSaplingIfNeeded()
  128. xGetCoalIfNeeded()
  129. xDropToChest()
  130.  
  131. if debut == 0 then
  132. os.sleep(180)
  133. end
  134. end
  135. turtle.forward()
  136. xSuck()
  137. else
  138. turtle.forward()
  139. xSuck()
  140. end
  141. debut = 0
  142. end
  143.  
  144. function xThrow()
  145. for s=2,15 do
  146. turtle.select(s)
  147. toThrow = turtle.getItemDetail()
  148. if toThrow then
  149. if toThrow.name == 'minecraft:apple' then
  150. turtle.dropUp()
  151. end
  152. if toThrow.name == 'minecraft:torch' then
  153. turtle.dropUp()
  154. end
  155. if toThrow.name == 'minecraft:sapling' then
  156. turtle.turnRight()
  157. turtle.drop()
  158. turtle.turnLeft()
  159. end
  160. end
  161. end
  162. turtle.select(1)
  163. end
  164.  
  165. xGetCoalIfNeeded()
  166. xGetSaplingIfNeeded()
  167. debut = 1
  168.  
  169. while true do
  170. xCheckAround()
  171. xForward()
  172. end
Add Comment
Please, Sign In to add comment