Advertisement
EphemeralKap

Untitled

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