Saereth

TurtleRubberFarmMK6

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