Advertisement
EphemeralKap

Untitled

Nov 1st, 2018
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.94 KB | None | 0 0
  1. -- Kap's Lumberjack Turtle ver 1.0, 01/11/18
  2. local tArgs = {...}
  3. local runs = tonumber(tArgs[1])
  4.  
  5. local trees = 7
  6. local treeRows = 4
  7. local spacing = 1
  8. local direction = true
  9.  
  10. local height = 1
  11. local maxHeight = 5
  12.  
  13. function ChopTree()
  14. turtle.dig()
  15. turtle.forward()
  16. turtle.digDown()
  17. Plant()
  18.  
  19. while turtle.detectUp() do
  20. if height >= maxHeight then break end
  21. turtle.digUp()
  22. turtle.up()
  23. height = height + 1
  24. os.sleep(1)
  25. end
  26.  
  27. while not turtle.detectDown() do
  28. turtle.down()
  29. height = height - 1
  30. end
  31. end
  32.  
  33.  
  34. function Plant()
  35. turtle.select(2)
  36. turtle.placeDown()
  37. end
  38.  
  39.  
  40. function Return()
  41. direction = true
  42. turtle.turnLeft()
  43. for i=1, (treeRows + (spacing * 2)) do
  44. turtle.forward()
  45. end
  46. turtle.turnLeft()
  47. OffloadWood()
  48. end
  49.  
  50. function OffloadWood()
  51. turtle.turnLeft()
  52. turtle.turnLeft()
  53.  
  54. for i=3, 16 do
  55. turtle.select(i)
  56. turtle.drop()
  57. end
  58.  
  59. Restock()
  60. end
  61.  
  62. function Restock()
  63. turtle.down()
  64. turtle.select(2)
  65. turtle.suck(64 - turtle.getItemCount(2))
  66.  
  67. GrabFuel()
  68. end
  69.  
  70. function GrabFuel()
  71. turtle.select(1)
  72. turtle.suckDown(64 - turtle.getItemCount(1))
  73. turtle.up()
  74. end
  75.  
  76. function Refuel()
  77. if turtle.getFuelLevel(1) < 400 then
  78. turtle.select(1)
  79. turtle.refuel(1)
  80. end
  81. end
  82.  
  83. function FillFurnaces()
  84. -- pick up wood and update woodTable
  85. turtle.turnLeft()
  86. turtle.turnLeft()
  87. for i=3, 16 do
  88. turtle.select(i)
  89. turtle.suck()
  90. end
  91.  
  92. --move up to furnaces
  93. turtle.digUp()
  94. turtle.up()
  95. turtle.digUp()
  96. turtle.up()
  97. turtle.dig()
  98. turtle.forward()
  99.  
  100. -- Fill all furnaces
  101. for i=1, 4 do
  102. turtle.turnLeft()
  103. for j=3, 16 do
  104. turtle.select(j)
  105. if not turtle.drop() then break end
  106. end
  107. turtle.turnLeft()
  108. turtle.turnLeft()
  109. for j=3, 16 do
  110. turtle.select(j)
  111. if not turtle.drop() then break end
  112. end
  113. turtle.turnLeft()
  114. turtle.digUp()
  115. turtle.up()
  116. end
  117.  
  118. -- move back down and drop off leftover wood
  119. turtle.turnLeft()
  120. turtle.turnLeft()
  121. turtle.digDown()
  122. turtle.down()
  123. turtle.digDown()
  124. turtle.down()
  125. turtle.digDown()
  126. turtle.down()
  127. turtle.dig()
  128. turtle.forward()
  129. turtle.digDown()
  130. turtle.down()
  131. turtle.digDown()
  132. turtle.down()
  133. turtle.turnLeft()
  134. turtle.turnLeft()
  135.  
  136. for i=3, 16 do
  137. turtle.select(i)
  138. turtle.drop()
  139. end
  140.  
  141. -- now go pick up charcoal
  142. -- move up to furnaces
  143. turtle.digUp()
  144. turtle.up()
  145. turtle.digUp()
  146. turtle.up()
  147. turtle.dig()
  148. turtle.forward()
  149.  
  150. -- fetch from all furnaces
  151. for i=1, 4 do
  152. turtle.turnLeft()
  153. for j=3, 16 do
  154. turtle.select(j)
  155. if turtle.suck() then break end
  156. end
  157. turtle.turnLeft()
  158. turtle.turnLeft()
  159. for j=3, 16 do
  160. turtle.select(j)
  161. if turtle.suck() then break end
  162. end
  163. turtle.turnLeft()
  164. turtle.digUp()
  165. turtle.up()
  166. end
  167.  
  168. -- move back down and drop off charcoal
  169. turtle.turnLeft()
  170. turtle.turnLeft()
  171. turtle.digDown()
  172. turtle.down()
  173. turtle.digDown()
  174. turtle.down()
  175. turtle.digDown()
  176. turtle.down()
  177. turtle.dig()
  178. turtle.forward()
  179. turtle.digDown()
  180. turtle.down()
  181. turtle.digDown()
  182. turtle.down()
  183.  
  184. for i=3, 16 do
  185. turtle.select(i)
  186. turtle.dropDown()
  187. end
  188.  
  189. turtle.up()
  190. end
  191.  
  192. function FetchDrops()
  193. -- todo
  194. end
  195.  
  196.  
  197. -- movement and execution
  198. for x=1, runs do
  199. for i=1, treeRows do
  200. Refuel()
  201. for j=1, trees do
  202. if turtle.detect() and not turtle.detectDown() then
  203. ChopTree()
  204. turtle.dig()
  205. turtle.forward()
  206. else
  207. turtle.forward()
  208. Plant()
  209. turtle.dig()
  210. turtle.forward()
  211. end
  212. end
  213. if i == treeRows then break end
  214. if direction then
  215. turtle.turnLeft()
  216. turtle.dig()
  217. turtle.forward()
  218. turtle.dig()
  219. turtle.forward()
  220. turtle.turnLeft()
  221. direction = false
  222. else
  223. turtle.turnRight()
  224. turtle.dig()
  225. turtle.forward()
  226. turtle.dig()
  227. turtle.forward()
  228. turtle.turnRight()
  229. direction = true
  230. end
  231. end
  232. Return()
  233.  
  234. if x % 1 == 0 then
  235. FillFurnaces()
  236. end
  237.  
  238. --if x % 10 == 0 then
  239. -- FetchDrops()
  240. --end
  241.  
  242. os.sleep(5)
  243. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement