Advertisement
EphemeralKap

Untitled

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