Drakaxx

Farm Tree Steam

May 6th, 2019
501
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.25 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,16 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,16 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 xGetCoalIfNeeded()
  37. if turtle.getFuelLevel() <= 1000 then
  38. turtle.select(16)
  39. turtle.suckDown(20)
  40. turtle.select(16)
  41. turtle.refuel()
  42. end
  43. turtle.select(1)
  44. end
  45.  
  46. function xDigIfNeeded()
  47. local success, data = turtle.inspect()
  48. if success then
  49. if data.name == 'minecraft:log' then
  50. turtle.dig()
  51. turtle.suck()
  52. putSaplingInRightPlaceIfNeeded()
  53. turtle.select(1)
  54. turtle.place()
  55. end
  56. else
  57. putSaplingInRightPlaceIfNeeded()
  58. turtle.select(1)
  59. turtle.place()
  60. end
  61. end
  62.  
  63. function xSuck()
  64. local success, data = turtle.inspect()
  65. if success then
  66. if data.name ~= 'minecraft:chest' then
  67. turtle.suck()
  68. end
  69. else
  70. turtle.suck()
  71. end
  72. end
  73.  
  74. function xCheckAround()
  75. putSaplingInRightPlaceIfNeeded()
  76. xDigIfNeeded()
  77. xSuck()
  78. turtle.turnLeft()
  79. xDigIfNeeded()
  80. xSuck()
  81. turtle.turnRight()
  82. turtle.turnRight()
  83. xDigIfNeeded()
  84. xSuck()
  85. turtle.turnLeft()
  86. xSuck()
  87. end
  88.  
  89. function checkIfNeedToSleep()
  90.  
  91. local dataSleep = turtle.getItemDetail(3)
  92. if dataSleep then
  93. os.sleep(180)
  94. xDropToChest()
  95. checkIfNeedToSleep()
  96. end
  97.  
  98. end
  99.  
  100. function xDropToChest()
  101. turtle.turnRight()
  102. turtle.turnRight()
  103. for n=2,16 do
  104. turtle.select(n)
  105. local dataToDropDown = turtle.getItemDetail()
  106. if dataToDropDown then
  107. if dataToDropDown.name == 'minecraft:log' then
  108. turtle.drop()
  109. end
  110. end
  111.  
  112. end
  113. turtle.turnLeft()
  114. turtle.turnLeft()
  115. turtle.select(1)
  116.  
  117. checkIfNeedToSleep()
  118. end
  119.  
  120. function xGetSaplingIfNeeded()
  121. if turtle.getItemCount(1) < 63 then
  122. turtle.select(1)
  123. turtle.turnRight()
  124. turtle.suck()
  125. turtle.turnLeft()
  126. end
  127. end
  128.  
  129. function xDropSaplingIfNeeded()
  130.  
  131. for q=2,16 do
  132. turtle.select(q)
  133. toThrowSapling = turtle.getItemDetail()
  134. if toThrowSapling then
  135. if toThrowSapling.name == 'minecraft:sapling' then
  136. turtle.dropUp()
  137. end
  138. end
  139. end
  140. turtle.select(1)
  141. end
  142.  
  143. function replaceIfBuggedAndForward()
  144. local successw, dataw = turtle.inspect()
  145. if successw then
  146. if dataw.name == 'minecraft:sapling' then
  147. turtle.turnRight()
  148. turtle.forward()
  149. elseif dataw.name == 'minecraft:chest' then
  150. turtle.turnRight()
  151. replaceIfBuggedAndForward()
  152. elseif dataw.name == 'chisel:marble2' then
  153. turtle.turnRight()
  154. turtle.turnRight()
  155. turtle.forward()
  156. else
  157. turtle.forward()
  158. end
  159. else
  160. turtle.forward()
  161. end
  162. end
  163.  
  164. function xForward()
  165. local successs, dataa = turtle.inspectDown()
  166. if successs then
  167. if dataa.name == 'minecraft:netherrack' then
  168. turtle.turnRight()
  169. turtle.turnRight()
  170. end
  171. if dataa.name == 'extrautils2:minichest' then
  172. if debut == 0 then
  173. turtle.turnRight()
  174. turtle.turnRight()
  175. end
  176. xThrow()
  177. xDropSaplingIfNeeded()
  178. xDropToChest()
  179. xGetSaplingIfNeeded()
  180. xGetCoalIfNeeded()
  181. end
  182. replaceIfBuggedAndForward()
  183. xSuck()
  184. else
  185. replaceIfBuggedAndForward()
  186. xSuck()
  187. end
  188. debut = 0
  189. end
  190.  
  191. function xThrow()
  192. for s=2,16 do
  193. turtle.select(s)
  194. toThrow = turtle.getItemDetail()
  195. if toThrow then
  196. if (toThrow.name ~= 'minecraft:log' and toThrow.name ~= 'minecraft:sapling') then
  197. turtle.dropUp()
  198. end
  199. if toThrow.name == 'minecraft:sapling' then
  200. turtle.turnRight()
  201. turtle.drop()
  202. turtle.turnLeft()
  203. end
  204. end
  205. end
  206. turtle.select(1)
  207. end
  208.  
  209. xGetCoalIfNeeded()
  210. xGetSaplingIfNeeded()
  211. debut = 1
  212.  
  213. while true do
  214. xCheckAround()
  215. xForward()
  216. end
Advertisement
Add Comment
Please, Sign In to add comment