Serval_Mart-Lag

trees.lua

May 27th, 2020
1,458
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.14 KB | None | 0 0
  1. local chest = peripheral.find("minecraft:ironchest_iron")
  2. local chest2 = peripheral.find("minecraft:chest")
  3. local furnace = peripheral.find("minecraft:furnace")
  4. local bottom = peripheral.wrap("bottom")
  5. function remove_tree()
  6. turtle.dig()
  7. while not turtle.forward() do end
  8. local i = 1
  9. local block, infos = turtle.inspectUp()
  10. while block and infos.name == "minecraft:log" do
  11. turtle.digUp()
  12. i = i + 1
  13. while not turtle.up() do end
  14. block, infos = turtle.inspectUp()
  15. end
  16.  
  17. for n = 2,i do
  18. while not turtle.down() do end
  19. end
  20. block, infos = turtle.inspectDown()
  21. if infos.name == "minecraft:log" then
  22. turtle.digDown()
  23. turtle.placeDown()
  24. end
  25. end
  26.  
  27. function clear_rangee()
  28. for a = 1,6 do
  29. for b = 1,4 do
  30. turtle.dig()
  31. while not turtle.forward() do end
  32. end
  33. remove_tree()
  34. end
  35. end
  36.  
  37. function fill_saplings()
  38. turtle.select(1)
  39. n = chest.size()
  40. while turtle.getItemCount() < 14 and n >= 1 do
  41. if chest.list()[n] ~= nil and chest.list()[n].name == "minecraft:sapling" then
  42.   chest.pushItems(bottom.getNameLocal(),n,14-turtle.getItemCount())
  43. end
  44. n = n - 1
  45. end
  46. end
  47.  
  48. function send_furnace()
  49. while furnace.list()[1] ~= nil and furnace.list()[2] ~= nil do
  50. sleep(1)
  51. end
  52. if furnace.list()[3] ~= nil then
  53. turtle.select(16)
  54. furnace.pushItems(bottom.getNameLocal(), 3, 64, 16)
  55. turtle.refuel(64)
  56. end
  57. nb = 0
  58. for i = 1,15 do
  59. turtle.select(i)
  60. if turtle.getItemCount() > 0 and turtle.getItemDetail().name ~= "minecraft:log" then
  61. chest.pullItems(bottom.getNameLocal(), i)
  62. --turtle.drop()
  63. else
  64. nb = nb + turtle.getItemCount()
  65. if nb > 70 then
  66. nb = nb - chest2.pullItems(bottom.getNameLocal(), i, nb - 70)
  67. end
  68. end
  69. end
  70. for i = 1, 15 do
  71. if nb % 7 ~= 0 then
  72. nb = nb - chest2.pullItems(bottom.getNameLocal(), i, nb % 7)
  73. end
  74. end
  75. nbn = nb*6/7
  76. for i = 1,15 do
  77. if nbn > 0 then
  78. nbn = nbn - furnace.pullItems(bottom.getNameLocal(),i,nbn,1)
  79. end
  80. if nbn == 0 then
  81. turtle.select(i)
  82. if turtle.getItemCount() > 0 then
  83. turtle.transferTo(1, turtle.getItemCount())
  84. end
  85. end
  86. end
  87. local n = chest2.size()
  88. while turtle.getItemCount() == 0 do
  89. if chest2.list()[n] ~= nil and chest2.list()[n].name == "minecraft:crafting_table" then
  90.   chest2.pushItems(bottom.getNameLocal(),n,1,15)
  91. end
  92. n = n - 1
  93. end
  94. turtle.select(15)
  95. turtle.equipLeft()
  96. chest2.pullItems(bottom.getNameLocal(), 15, 1, chest2.size())
  97. turtle.select(1)
  98. turtle.craft()
  99. furnace.pullItems(bottom.getNameLocal(), 1, turtle.getItemCount(), 2)
  100. chest2.pushItems(bottom.getNameLocal(), chest2.size(), 1, 15)
  101. turtle.select(15)
  102. turtle.equipLeft()
  103. chest2.pullItems(bottom.getNameLocal(), 15, 1, chest2.size())
  104. end
  105. --send_furnace()
  106.  
  107. function run_turn()
  108. fill_saplings()
  109. turtle.dig()
  110. while not turtle.forward() do end
  111. turtle.digUp()
  112. while not turtle.up() do end
  113. remove_tree()
  114. clear_rangee()
  115. turtle.turnRight()
  116. for i = 1,7 do
  117. turtle.dig()
  118. while not turtle.forward() do end
  119. end
  120. remove_tree()
  121. turtle.turnRight()
  122. clear_rangee()
  123. turtle.dig()
  124. while not turtle.forward() do end
  125. turtle.dig()
  126. while not turtle.forward() do end
  127. turtle.turnRight()
  128. for i = 1,8 do
  129. turtle.dig()
  130. while not turtle.forward() do end
  131. end
  132. turtle.turnRight()
  133. turtle.digDown()
  134. while not turtle.down() do end
  135. send_furnace()
  136. end
  137.  
  138. run_turn()
Advertisement
Add Comment
Please, Sign In to add comment