Advertisement
EphemeralKap

Untitled

Nov 1st, 2018
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.96 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 direction = true
  9.  
  10. local height = 1
  11. local maxHeight = 5
  12.  
  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. Offload()
  49. end
  50.  
  51. function Offload()
  52. turtle.turnLeft()
  53. turtle.turnLeft()
  54.  
  55. for i=3, 16 do
  56. turtle.select(i)
  57. turtle.drop()
  58. end
  59.  
  60. turtle.turnLeft()
  61. Restock()
  62. end
  63.  
  64. function Restock()
  65. turtle.select(2)
  66. turtle.suck(64 - turtle.getItemCount(2))
  67. turtle.turnLeft()
  68. GrabFuel()
  69. end
  70.  
  71. function GrabFuel()
  72. if turtle.getItemCount(1) < 16 then
  73. turtle.select(1)
  74. turtle.suckUp()
  75. end
  76. end
  77.  
  78. function Refuel()
  79. if turtle.getFuelLevel(1) < 400 then
  80. turtle.select(1)
  81. turtle.refuel(1)
  82. end
  83. end
  84.  
  85.  
  86. -- movement and execution
  87. for x=1, runs do
  88. for i=1, treeRows do
  89. Refuel()
  90. for j=1, trees do
  91. if turtle.detect() and not turtle.detectDown() then
  92. ChopTree()
  93. turtle.dig()
  94. turtle.forward()
  95. else
  96. turtle.forward()
  97. Plant()
  98. turtle.dig()
  99. turtle.forward()
  100. end
  101. end
  102. if i == treeRows then break end
  103. if direction then
  104. turtle.turnLeft()
  105. turtle.dig()
  106. turtle.forward()
  107. turtle.dig()
  108. turtle.forward()
  109. turtle.turnLeft()
  110. direction = false
  111. else
  112. turtle.turnRight()
  113. turtle.dig()
  114. turtle.forward()
  115. turtle.dig()
  116. turtle.forward()
  117. turtle.turnRight()
  118. direction = true
  119. end
  120. end
  121. Return()
  122. os.sleep(120)
  123. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement