Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Function to check if there is a block in front
- function isBlockInFront()
- return turtle.detect()
- end
- -- Function to dig and suck blocks in front
- function digAndSuck()
- turtle.dig()
- turtle.suck()
- end
- -- Function to plant a sapling
- function plantSapling()
- -- Find sapling in inventory
- for i = 1, 16 do
- local item = turtle.getItemDetail(i)
- if item and item.name == "minecraft:sapling" then -- You can change this to the specific sapling type
- turtle.select(i)
- turtle.place()
- return true
- end
- end
- print("No saplings found!")
- return false
- end
- -- Main loop
- while true do
- if isBlockInFront() then
- digAndSuck()
- if plantSapling() then
- print("Sapling planted. Waiting for tree to grow...")
- -- Sleep for a while before checking again
- -- Adjust the sleep time as needed
- os.sleep(300) -- 300 seconds = 5 minutes
- else
- print("Failed to plant sapling. Waiting to try again...")
- os.sleep(60) -- Wait 1 minute before trying again
- end
- else
- print("No block detected. Waiting...")
- os.sleep(60) -- Wait 1 minute before checking again
- end
- end
Advertisement
Comments
-
- pls add me i have question
- https://steamcommunity.com/profiles/76561199091249086
Add Comment
Please, Sign In to add comment
Advertisement