Advertisement
asweigart

Untitled

Jul 29th, 2016
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. -- Chop Tree program
  2. -- By Al Sweigart
  3. -- al@inventwithpython.com
  4. -- Run with tree in front of turtle
  5. -- to chop it down.
  6.  
  7. if not turtle.detect() then
  8. return -- nothing there, so exit
  9. end
  10.  
  11. print('Chopping tree...')
  12.  
  13. turtle.dig() -- chop base
  14. turtle.forward() -- move under tree
  15. while turtle.compareUp() do
  16. -- keep chopping until no more wood
  17. turtle.digUp()
  18. turtle.up()
  19. end
  20.  
  21. -- move back to ground
  22. while not turtle.detectDown() do
  23. turtle.down()
  24. end
  25.  
  26. print('Done chopping tree.')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement