EphemeralKap

Untitled

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