Advertisement
EphemeralKap

Untitled

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