Advertisement
asweigart

choptree

Aug 4th, 2016
774
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. --[[Tree Chopping program by Al Sweigart
  2. Chops down the tree in front of turtle.]]
  3.  
  4. if not turtle.detect() then
  5. error('Could not find tree!')
  6. end
  7.  
  8. print('Chopping tree...')
  9.  
  10. if not turtle.dig() then -- chop base of tree
  11. error('Turtle needs a digging tool!')
  12. end
  13.  
  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 down 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