JustJurt

Tree Farm

Jul 21st, 2024 (edited)
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.13 KB | Gaming | 0 0
  1.  
  2. function selectItem(item)
  3.     item = "minecraft:" .. item
  4.     local itemdetail = turtle.getItemDetail()
  5.     if itemdetail ~= nil and itemdetail.name == item then
  6.         return true
  7.     end
  8.     for i = 1, 16, 1 do
  9.         turtle.select(i)
  10.         itemdetail = turtle.getItemDetail()
  11.         if itemdetail ~= nil and itemdetail.name == item then
  12.             return true
  13.         end
  14.     end
  15.     return false
  16. end
  17.  
  18. function isBlock(block)
  19.     block = "minecraft:" .. block
  20.     local isThere, data = turtle.inspect()
  21.     if block == data.name then
  22.         return true
  23.     end
  24.     return false
  25. end
  26.  
  27.  
  28.  
  29. while (true) do
  30.     repeat
  31.         if selectItem("bone_meal") then
  32.             turtle.place()
  33.         end
  34.     until isBlock("spruce_log")
  35.     height = 0
  36.     while isBlock("spruce_log") do
  37.         turtle.dig()
  38.         if turtle.detectUp() then turtle.digUp() end
  39.         turtle.up()
  40.         height = height + 1
  41.     end
  42.     for i = 1, height, 1 do
  43.         if turtle.detectDown() then turtle.digDown() end
  44.         turtle.down()
  45.     end
  46.     if selectItem("spruce_sapling") then
  47.         turtle.place()
  48.     end
  49. end
Advertisement
Add Comment
Please, Sign In to add comment