Advertisement
EphemeralKap

Untitled

Nov 1st, 2018
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.00 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. turtle.drop()
  106. end
  107. turtle.turnLeft()
  108. turtle.turnLeft()
  109. for j=3, 16 do
  110. turtle.select(j)
  111. turtle.drop()
  112. end
  113. turtle.turnLeft()
  114. if i ~= 4 then
  115. turtle.digUp()
  116. turtle.up()
  117. end
  118. end
  119.  
  120. -- move back down and drop off leftover wood
  121. turtle.turnLeft()
  122. turtle.turnLeft()
  123. turtle.digDown()
  124. turtle.down()
  125. turtle.digDown()
  126. turtle.down()
  127. turtle.digDown()
  128. turtle.down()
  129. turtle.dig()
  130. turtle.forward()
  131. turtle.digDown()
  132. turtle.down()
  133. turtle.digDown()
  134. turtle.down()
  135. turtle.turnLeft()
  136. turtle.turnLeft()
  137.  
  138. for i=3, 16 do
  139. turtle.select(i)
  140. turtle.drop()
  141. end
  142.  
  143. -- now go pick up charcoal
  144. -- move up to furnaces
  145. turtle.digUp()
  146. turtle.up()
  147. turtle.digUp()
  148. turtle.up()
  149. turtle.dig()
  150. turtle.forward()
  151.  
  152. -- fetch from all furnaces
  153. for i=1, 4 do
  154. turtle.turnLeft()
  155. for j=3, 16 do
  156. turtle.select(j)
  157. if turtle.suck() then break end
  158. end
  159. turtle.turnLeft()
  160. turtle.turnLeft()
  161. for j=3, 16 do
  162. turtle.select(j)
  163. if turtle.suck() then break end
  164. end
  165. turtle.turnLeft()
  166. if i ~= 4 then
  167. turtle.digUp()
  168. turtle.up()
  169. end
  170. end
  171.  
  172. -- move back down and drop off charcoal
  173. turtle.turnLeft()
  174. turtle.turnLeft()
  175. turtle.digDown()
  176. turtle.down()
  177. turtle.digDown()
  178. turtle.down()
  179. turtle.digDown()
  180. turtle.down()
  181. turtle.dig()
  182. turtle.forward()
  183. turtle.digDown()
  184. turtle.down()
  185. turtle.digDown()
  186. turtle.down()
  187.  
  188. for i=3, 16 do
  189. turtle.select(i)
  190. turtle.dropDown()
  191. end
  192.  
  193. turtle.up()
  194. end
  195.  
  196. function FetchDrops()
  197. -- todo
  198. end
  199.  
  200.  
  201. -- movement and execution
  202. for x=1, runs do
  203. if x % 1 == 0 then
  204. FillFurnaces()
  205. end
  206.  
  207. for i=1, treeRows do
  208. Refuel()
  209. for j=1, trees do
  210. if turtle.detect() and not turtle.detectDown() then
  211. ChopTree()
  212. turtle.dig()
  213. turtle.forward()
  214. else
  215. turtle.forward()
  216. Plant()
  217. turtle.dig()
  218. turtle.forward()
  219. end
  220. end
  221. if i == treeRows then break end
  222. if direction then
  223. turtle.turnLeft()
  224. turtle.dig()
  225. turtle.forward()
  226. turtle.dig()
  227. turtle.forward()
  228. turtle.turnLeft()
  229. direction = false
  230. else
  231. turtle.turnRight()
  232. turtle.dig()
  233. turtle.forward()
  234. turtle.dig()
  235. turtle.forward()
  236. turtle.turnRight()
  237. direction = true
  238. end
  239. end
  240. Return()
  241.  
  242. if x % 1 == 0 then
  243. FillFurnaces()
  244. end
  245.  
  246. --if x % 10 == 0 then
  247. -- FetchDrops()
  248. --end
  249.  
  250. os.sleep(5)
  251. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement