Advertisement
EphemeralKap

Untitled

Nov 1st, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.07 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.  
  97.  
  98. -- Fill all furnaces
  99. for i=1, furnaceCount do
  100. turtle.turnLeft()
  101. for j=3, 16 do
  102. turtle.select(j)
  103. turtle.drop()
  104. end
  105. turtle.turnRight()
  106. if i < furnaceCount then turtle.forward() end
  107. end
  108.  
  109. -- move back and drop off leftover wood
  110. turtle.turnRight()
  111. for i=1, 11 do
  112. turtle.forward()
  113. end
  114. turtle.turnRight()
  115.  
  116. for i=3, 16 do
  117. turtle.select(i)
  118. turtle.drop()
  119. end
  120.  
  121. -- fill furnaces with charcoal
  122. turtle.down()
  123. turtle.turnRight()
  124. for i=3, 16 do
  125. turtle.select(i)
  126. turtle.suckDown()
  127. end
  128.  
  129. turtle.forward()
  130. turtle.turnLeft()
  131. turtle.forward()
  132. turtle.turnRight()
  133.  
  134. for i=1,furnaceCount do
  135. for j=3, 16 do
  136. turtle.select(j)
  137. turtle.dropUp()
  138. end
  139. if i ~= furnaceCount then
  140. turtle.dig()
  141. turtle.forward()
  142. end
  143. end
  144.  
  145. --move back, drop remainder coal off.
  146. turtle.turnRight()
  147. turtle.forward()
  148. turtle.turnRight()
  149. for i=1, 11 do
  150. turtle.forward()
  151. end
  152.  
  153. for i=3, 16 do
  154. turtle.select(i)
  155. turtle.dropDown()
  156. end
  157.  
  158. -- now get charcoal from furnaces
  159. turtle.back()
  160. turtle.digUp()
  161. turtle.up()
  162. turtle.digUp()
  163. turtle.up()
  164. turtle.turnRight()
  165. turtle.forward()
  166. turtle.turnRight()
  167.  
  168. -- fetch from all furnaces
  169. for i=1, furnaceCount do
  170. for j=3, 16 do
  171. turtle.suckDown()
  172. end
  173. if i ~= furnaceCount then
  174. turtle.dig()
  175. turtle.forward()
  176. end
  177. end
  178.  
  179. -- move back down and drop off charcoal
  180. turtle.turnRight()
  181. turtle.dig()
  182. turtle.forward()
  183. turtle.digDown()
  184. turtle.down()
  185. turtle.digDown()
  186. turtle.down()
  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. for x=1, runs do
  210. if x % 1 == 0 then
  211. FillFurnaces()
  212. end
  213.  
  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 % 1 == 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