Advertisement
EphemeralKap

Untitled

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