Saereth

TurtleTreeFarm+Leaves+noFuelV1

May 20th, 2014
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function f(loc)
  2. while not turtle[loc]() do
  3. sleep(0.5)
  4. end
  5. end
  6. function up() f("up") end
  7. function down() f("down") end
  8. function fw() f("forward") end
  9. function back() f("back") end
  10. function l() f("turnLeft") end
  11. function r() f("turnRight") end
  12. function d() turtle.dig() end
  13. function du() turtle.digUp() end
  14. function dd() turtle.digDown() end
  15. function c(x)
  16. for i=1,x do d() fw() du() dd() end
  17. end
  18.  
  19. function makeTree()
  20. if turtle.getItemCount(1)==0 then
  21. print("Not enough Saplings.")
  22. return
  23. end
  24.  
  25. if turtle.getItemCount(2)==0 then
  26. print("Not enough BoneMeal.")
  27. return
  28. end
  29. turtle.select(1)
  30. turtle.place()
  31. sleep(1)
  32. turtle.select(2)
  33. turtle.place()
  34. sleep(1)
  35. end
  36.  
  37.  
  38.  
  39. function resetPos()
  40. print("Resetting position.")
  41. sleep(2)
  42. r=0
  43. while r==0 do
  44. turtle.down()
  45. if turtle.detectDown()==true then
  46. r=1
  47. end
  48. end
  49. turtle.back()
  50. end
  51.  
  52. --function cutTree()
  53. -- sleep(2)
  54.  
  55.  
  56. --print("Cutting Tree.")
  57. -- sleep(2)
  58. -- turtle.dig()
  59. -- turtle.forward()
  60. -- y=1
  61. -- while y==1 do
  62. -- turtle.digUp()
  63. -- turtle.up()
  64. -- if turtle.detectUp()==false then
  65. -- y=0
  66. -- end
  67. -- end
  68. --
  69. --resetPos()
  70. --end
  71.  
  72. function cutTree()
  73. print("tree cut")
  74. hi = 0
  75. while not turtle.detectUp() do
  76. up() hi=hi+1
  77. end
  78. du() up() du() up() du() l() l()
  79. c(1) r() c(2) r() c(4) r() c(4) r()
  80. c(4) r() c(1) r() c(3) l() c(2) l()
  81. c(2) back() l() c(1) l() down()
  82. for r=1,hi do dd() down() end
  83. dd() back()
  84. down() down()
  85. print(hi)
  86. end
  87.  
  88. function checkMats()
  89. -- Checking saplings slot
  90. print("Checking for mats.")
  91. sleep(2)
  92. if turtle.getItemCount(1)==0 then
  93. print("Not enough Saplings.")
  94. s=1
  95. turtle.turnLeft()
  96. turtle.select(1)
  97. turtle.suck()
  98. turtle.turnRight()
  99. if turtle.getItemCount(1)>0 then
  100. s=0
  101. end
  102. end
  103.  
  104. -- Checking bonemeal slot
  105. if turtle.getItemCount(2)==0 then
  106. print("Not enough bonemeal.")
  107. turtle.turnLeft()
  108. turtle.turnLeft()
  109. turtle.select(1)
  110. turtle.suck()
  111. turtle.turnRight()
  112. turtle.turnRight()
  113. end
  114.  
  115. end
  116.  
  117. function checkStop()
  118. if s==0 then
  119. shell.exit()
  120. end
  121. end
  122.  
  123. function ConsolidateMats()
  124. turtle.turnLeft()
  125. print("Consolidating saplings.")
  126. for i=3,15 do
  127. turtle.select(i)
  128.  
  129. if turtle.compareTo(1) then -- It's a sapling not in slot one
  130. turtle.drop() -- put it in the chest to our left
  131. end
  132. end
  133. turtle.turnRight()
  134.  
  135. print("Sending all other mats to processing.")
  136. sleep(2)
  137. for i=3,15 do
  138. turtle.select(i)
  139. turtle.dropDown()
  140. end
  141. end
  142.  
  143. while true do
  144. makeTree()
  145. checkMats()
  146. cutTree()
  147. ConsolidateMats()
  148. checkStop()
  149. end
Advertisement
Add Comment
Please, Sign In to add comment