Advertisement
JJC15433

Lazy ccRestitched Tree Farm

Oct 30th, 2021 (edited)
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.24 KB | None | 0 0
  1. --[[ | Lazy tree farm.
  2. |
  3. | - Bonemeal goes in chest to right of turtle.
  4. | - Saplings funnel into chest under turtle (Hopperhock used here since pack has Botania)
  5. | - Block 8 blocks above sapling space in front of turtle
  6. | - Place next to Skeleton farm for maximum AFK efficiency
  7. |
  8. | - Enjoy
  9. |
  10. --]]
  11.  
  12. local FUEL_THRESHOLD = 80;
  13. local SLOT_COUNT = 16;
  14. local i, found, slotItem, currSlot, present, block, presentBelow, blockBelow = 1, false, nil, nil, turtle.inspect(), turtle.inspectDown();
  15.  
  16. -- in case chunk is unloaded or server crashes mid-routine
  17. while not presentBelow do
  18. turtle.Down();
  19. presentBelow, blockBelow = turtle.inspectDown();
  20. present, block = turtle.inspect();
  21. end
  22. while present and (not (block.name == "minecraft:oak_sapling" or block.name == "minecraft:oak_log")) and i <= 4 do
  23. turtle.turnLeft();
  24. present, block = turtle.inspect();
  25. i = i + 1;
  26. end
  27. if i == 4 and present and not (block.name == "minecraft:oak_sapling" or block.name == "minecraft:oak_log") then
  28. assert(false, "Something is horribly wrong. Get Kammon.");
  29. end
  30.  
  31. -- main function loop
  32. while true do
  33. term.clear();
  34. print("Current fuel: "..turtle.getFuelLevel());
  35. print(os.getComputerLabel().." will cease function below "..FUEL_THRESHOLD..".");
  36. print("Please make sure to drop Charcoal and Bone Meal in the area to keep me running.");
  37. if turtle.getFuelLevel() < FUEL_THRESHOLD then
  38. found = false;
  39. while not found do
  40. for i = 1, SLOT_COUNT do
  41. slotItem = turtle.getItemDetail(i)
  42. if slotItem and slotItem.name == "minecraft:charcoal" then
  43. turtle.select(i);
  44. found = true;
  45. end
  46. end
  47. if not found then
  48. turtle.turnRight(); turtle.turnRight();
  49. if not turtle.suck() then
  50. print("Out of usable fuel. Please drop charcoal in the area.");
  51. os.sleep(300);
  52. term.clear();
  53. end
  54. turtle.turnLeft(); turtle.turnLeft();
  55. else
  56. turtle.refuel();
  57. end
  58. end
  59. end
  60. while present do
  61. if block.name == "minecraft:oak_sapling" then
  62. i = 1
  63. found = false;
  64. while i <= SLOT_COUNT and not found do
  65. slotItem = turtle.getItemDetail(i)
  66. if slotItem and slotItem.name == "minecraft:bone_meal" then
  67. turtle.select(i);
  68. found = true;
  69. end
  70. i = i + 1;
  71. end
  72. if not found then turtle.turnRight(); turtle.suck(); turtle.turnLeft() end
  73. turtle.place();
  74. elseif block.name == "minecraft:oak_log" then
  75. while present and block.name == "minecraft:oak_log" do
  76. turtle.dig();
  77. turtle.digUp();
  78. turtle.up();
  79. present, block = turtle.inspect();
  80. end
  81. while not turtle.detectDown() do turtle.down() end
  82. end
  83. present, block = turtle.inspect();
  84. end
  85. if not present then
  86. os.sleep(5);
  87. found = false;
  88. i = 1;
  89. while i <= SLOT_COUNT and not found do
  90. slotItem = turtle.getItemDetail(i);
  91. if slotItem and slotItem.name == "minecraft:oak_sapling" then
  92. turtle.select(i);
  93. found = true;
  94. end
  95. i = i + 1;
  96. end
  97. if not found then turtle.suckDown() end
  98. turtle.place();
  99. end
  100. present, block = turtle.inspect();
  101. for i = 1, 16 do
  102. slotItem = turtle.getItemDetail(i);
  103. if slotItem and slotItem.name == "minecraft:oak_log" then
  104. turtle.select(i);
  105. turtle.dropUp()
  106. end
  107. end
  108. end
  109.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement