Advertisement
TheFlowZone00

simple turtle log farm

May 21st, 2024
964
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.26 KB | Source Code | 0 0
  1. -- Function to check if there is a block in front
  2. function isBlockInFront()
  3.     return turtle.detect()
  4. end
  5.  
  6. -- Function to dig and suck blocks in front
  7. function digAndSuck()
  8.     turtle.dig()
  9.     turtle.suck()
  10. end
  11.  
  12. -- Function to plant a sapling
  13. function plantSapling()
  14.     -- Find sapling in inventory
  15.     for i = 1, 16 do
  16.         local item = turtle.getItemDetail(i)
  17.         if item and item.name == "minecraft:sapling" then -- You can change this to the specific sapling type
  18.             turtle.select(i)
  19.             turtle.place()
  20.             return true
  21.         end
  22.     end
  23.     print("No saplings found!")
  24.     return false
  25. end
  26.  
  27. -- Main loop
  28. while true do
  29.     if isBlockInFront() then
  30.         digAndSuck()
  31.         if plantSapling() then
  32.             print("Sapling planted. Waiting for tree to grow...")
  33.             -- Sleep for a while before checking again
  34.             -- Adjust the sleep time as needed
  35.             os.sleep(300) -- 300 seconds = 5 minutes
  36.         else
  37.             print("Failed to plant sapling. Waiting to try again...")
  38.             os.sleep(60) -- Wait 1 minute before trying again
  39.         end
  40.     else
  41.         print("No block detected. Waiting...")
  42.         os.sleep(60) -- Wait 1 minute before checking again
  43.     end
  44. end
Advertisement
Comments
  • bairi
    12 days
    # text 0.08 KB | 0 0
    1. pls add me i have question
    2. https://steamcommunity.com/profiles/76561199091249086
Add Comment
Please, Sign In to add comment
Advertisement