Advertisement
EphemeralKap

Untitled

Nov 1st, 2018
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.32 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 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. turtle.turnLeft()
  105. for j=3, 16 do
  106. turtle.select(j)
  107. if turtle.drop() 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.digUp()
  170. turtle.up()
  171. turtle.digUp()
  172. turtle.up()
  173. turtle.turnRight()
  174. turtle.forward()
  175. turtle.turnRight()
  176.  
  177. -- fetch from all furnaces
  178. for i=1, furnaceCount do
  179. for j=3, 16 do
  180. turtle.suckDown()
  181. end
  182. if i < furnaceCount then
  183. turtle.dig()
  184. turtle.forward()
  185. end
  186. end
  187.  
  188. -- move back down and drop off charcoal
  189. turtle.turnRight()
  190. turtle.dig()
  191. turtle.forward()
  192. turtle.digDown()
  193. turtle.down()
  194. turtle.digDown()
  195. turtle.down()
  196. turtle.turnRight()
  197.  
  198. for i=1, furnaceCount do
  199. turtle.forward()
  200. end
  201.  
  202.  
  203. for i=3, 16 do
  204. turtle.select(i)
  205. turtle.dropDown()
  206. end
  207.  
  208. turtle.up()
  209. turtle.turnLeft()
  210. end
  211.  
  212. function FetchDrops()
  213. -- todo
  214. end
  215.  
  216.  
  217. -- movement and execution
  218. turtle.turnLeft()
  219. turtle.turnLeft()
  220. for x=1, runs do
  221. if x % 1 == 0 then
  222. FillFurnaces()
  223. end
  224.  
  225. for i=1, treeRows do
  226. Refuel()
  227. for j=1, trees do
  228. if turtle.detect() and not turtle.detectDown() then
  229. ChopTree()
  230. turtle.dig()
  231. turtle.forward()
  232. else
  233. turtle.forward()
  234. Plant()
  235. turtle.dig()
  236. turtle.forward()
  237. end
  238. end
  239. if i == treeRows then break end
  240. if direction then
  241. turtle.turnLeft()
  242. turtle.dig()
  243. turtle.forward()
  244. turtle.dig()
  245. turtle.forward()
  246. turtle.turnLeft()
  247. direction = false
  248. else
  249. turtle.turnRight()
  250. turtle.dig()
  251. turtle.forward()
  252. turtle.dig()
  253. turtle.forward()
  254. turtle.turnRight()
  255. direction = true
  256. end
  257. end
  258. Return()
  259.  
  260. if x % 1 == 0 then
  261. FillFurnaces()
  262. end
  263.  
  264. --if x % 10 == 0 then
  265. -- FetchDrops()
  266. --end
  267.  
  268. os.sleep(5)
  269. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement