Advertisement
Reskatron

treeturtle

Feb 12th, 2024
912
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.05 KB | Gaming | 0 0
  1. -- Function to cut down a tree
  2. function cutTree()
  3.     turtle.dig()  -- Dig the block in front
  4.     turtle.forward()  -- Move forward
  5.     while turtle.detectUp() do
  6.         turtle.digUp()  -- Dig the block above if it exists
  7.         turtle.up()  -- Move up
  8.     end
  9.     while not turtle.detectDown() do
  10.         turtle.down()  -- Move down until reaching the ground
  11.     end
  12.     turtle.back()  -- Move back to the starting position
  13. end
  14.  
  15. -- Function to plant an oak sapling
  16. function plantSapling()
  17.     turtle.select(1)  -- Select the slot with oak saplings
  18.     turtle.place()  -- Place the sapling on the ground
  19. end
  20.  
  21. -- Main program
  22. turtle.select(1)  -- Select the slot with oak saplings (assuming it's in slot 1)
  23. while true do
  24.     -- Check if there's a tree in front
  25.     while turtle.detect() do
  26.         cutTree()  -- Cut down the tree
  27.     end
  28.  
  29.     -- Plant a sapling and wait for it to grow
  30.     plantSapling()  -- Plant an oak sapling
  31.     print("Waiting for the sapling to grow...")
  32.     os.sleep(600)  -- Wait for 10 minutes (adjust as needed)
  33. end
  34.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement