Advertisement
Spiker985

FTB - CharcoalGen

Mar 3rd, 2013
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.46 KB | None | 0 0
  1. local treeGrow = false
  2. local tArgs = {...}
  3.  
  4. function plant()
  5. print("Planting Saplings!")
  6. if turtle.compareDown(turtle.select(15)) then --Chest/Block the turtle starts on
  7. turtle.forward()
  8. turtle.forward()
  9. turtle.turnLeft()
  10. turtle.select(1) --Sapling
  11. turtle.place()
  12. turtle.turnRight()
  13. turtle.back()
  14. turtle.place()
  15. turtle.turnLeft()
  16. turtle.place()
  17. turtle.turnRight()
  18. turtle.back()
  19. turtle.place()
  20. end
  21. print("Planting Complete!")
  22. end
  23.  
  24. function grow()
  25. print("Growing Plants!")
  26. for i = 1,5 do
  27. turtle.select(2) -- Bonemeal
  28. turtle.place()
  29. end
  30. if turtle.compare(turtle.select(1)) then --Sapling
  31. noTreeGrowth()
  32. else
  33. treeGrow = true
  34. end
  35. end
  36.  
  37. function fell()
  38. print("Felling The Tree!")
  39. turtle.dig()
  40. turtle.forward()
  41. while turtle.detect() or turtle.detectUp() do
  42. turtle.digUp()
  43. turtle.dig()
  44. turtle.up()
  45. end
  46. turtle.turnRight()
  47. turtle.back()
  48. turtle.turnLeft()
  49. while not turtle.compareDown(turtle.select(16)) and turtle.detectDown() or turtle.detect() do --Dirt
  50. turtle.digDown()
  51. turtle.down()
  52. turtle.dig()
  53. end
  54. turtle.turnRight()
  55. turtle.forward()
  56. turtle.turnLeft()
  57. turtle.back()
  58. treeGrow = false
  59. end
  60.  
  61. function noTreeGrowth()
  62. print("Growth Attempt Failed!")
  63. turtle.dig()
  64. turtle.forward()
  65. turtle.turnLeft()
  66. turtle.dig()
  67. turtle.turnRight()
  68. turtle.dig()
  69. turtle.forward()
  70. turtle.turnLeft()
  71. turtle.dig()
  72. turtle.turnRight()
  73. turtle.back()
  74. turtle.back()
  75. treeGrow = false
  76. end
  77.  
  78. function plantNGrow()
  79. plant()
  80. grow()
  81. end
  82.  
  83. function dropItems() --Selects slots 3-14 and deposits them in the chest
  84. print("Dropping Items in slots 3-12...")
  85. n = 3
  86. for i = 1,12 do
  87. turtle.select(n)
  88. turtle.dropDown()
  89. n = n + 1
  90. end
  91. print("Done Dropping...")
  92. end
  93.  
  94. function refuel()
  95. print("Refueling...")
  96. turtle.select(3)
  97. turtle.refuel()
  98. turtle.select(4)
  99. turtle.refuel()
  100. end
  101.  
  102. print("Plant, Grow, Fell, Drop, Loop, Refuel or Stop?")
  103. input = read()
  104.  
  105. if input == "Plant" or input == "plant" or tArgs[1] == "Plant" or tArgs[1] == "plant" then
  106. plant()
  107. end
  108.  
  109. if input == "Grow" or input == "grow" or tArgs[1] == "Grow" or tArgs[1] == "grow" then
  110. grow()
  111. end
  112.  
  113. if input == "Fell" or input == "fell" or tArgs[1] == "plant" or tArgs[1] == "fell" then
  114. fell()
  115. end
  116.  
  117. if input == "Drop" or input == "drop" or tArgs[1] == "Drop" or tArgs[1] == "drop" then
  118. dropItems()
  119. end
  120.  
  121. if input == "Refuel" or input == "refuel" then
  122. refuel()
  123. end
  124.  
  125. if input == "Stop" or input == "stop" then
  126. print("Stopping...")
  127. sleep(1)
  128. shell.run("reboot")
  129. end
  130.  
  131. while input == "Loop" or input == "loop" or tArgs[1] == "Loop" or tArgs[1] == "loop"  do
  132.  
  133. if turtle.detect() then
  134. if turtle.compare(turtle.select(1)) then --Sapling
  135. grow()
  136. end
  137. else
  138. plantNGrow()
  139. while treeGrow == false do
  140. plantNGrow()
  141. end
  142. if treeGrow == true then
  143. fell()
  144. if turtle.getFuelLevel() <= 200 then
  145. refuel()
  146. end
  147. dropItems()
  148. end
  149. end
  150.  
  151. if turtle.getItemCount(1) <= 4 then --If Sapling amount is <= 4
  152. print("Need more Saplings!")
  153. write("Continue?")
  154. answer = read()
  155.  
  156. if answer == "y" or answer == "yes" then
  157. print("Continuing...")
  158. sleep(1)
  159. shell.run(shell.getRunningProgram(), "loop")
  160. end
  161.  
  162. if answer == "n" or answer == "no" then
  163. print("Stopping...")
  164. sleep(1)
  165. shell.run("reboot")
  166. end
  167. end
  168.  
  169. if turtle.getItemCount(2) <= 5 then --If Bonemeal ammount is <= 5
  170. print("Need more Bonemeal!")
  171. write("Continue?")
  172. answerB = read()
  173.  
  174. if answerB == "y" or answerB == "yes" then
  175. print("Continuing...")
  176. sleep(1)
  177. end
  178.  
  179. if answerB == "n" or answerB == "no" then
  180. print("Stopping...")
  181. sleep(1)
  182. shell.shutdown()
  183. end
  184. end
  185. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement