DaddyTigerOf3

CC-Turtle-Tree-Farm

Aug 4th, 2021 (edited)
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.99 KB | None | 0 0
  1. local saplings = 1 -- the slot where the saplings are
  2. turtle.select(saplings) -- select the saplings
  3. while turtle.getItemCount(saplings) > 0 do -- while more saplings in inventory
  4.     for i = 1, 8 do -- plant 8 saplings in a row
  5.         turtle.turnRight()
  6.         if not turtle.compare() then -- if not a sapling, then a tree grew
  7.             turtle.dig()
  8.             turtle.forward()
  9.             while turtle.detectUp() do -- dig tree out
  10.                 local _, block = turtle.inspectUp()
  11.                 if block.name == "minecraft:stone" or block.name == "minecraft:cobblestone" then
  12.                     break
  13.                 end
  14.                 turtle.digUp()
  15.                 turtle.up()
  16.             end
  17.             while not turtle.detectDown() do -- back down to ground
  18.                 turtle.down()
  19.             end
  20.             turtle.back()
  21.             turtle.place() -- put down new sapling
  22.         end
  23.         turtle.turnLeft()
  24.         turtle.forward()
  25.     end
  26.     -- turn around and line up for next pass
  27.     turtle.turnRight()
  28.     turtle.forward()
  29.     turtle.forward()
  30.     turtle.turnRight()
  31.     turtle.forward()
  32.     os.sleep(30) -- sleep for 30 seconds to allow trees to grow
  33. end
Add Comment
Please, Sign In to add comment