Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2016
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. var {loop, move, motor, read, sleep, out} = require('robot-loop')
  2. loop(main, 'ip address', {
  3. teamName: '',
  4. teamColor: '',
  5. game: ''
  6. })
  7.  
  8. var steer = move()
  9.  
  10. function main (input, rot) {
  11. if (input === 'f') {
  12. f(rot)
  13. } else if (input === 'b') {
  14. b(rot)
  15. } else if (input === 'l') {
  16. l(rot)
  17. } else if (input === 'r') {
  18. r(rot)
  19. }
  20. }
  21.  
  22. function f (rot) {
  23. out('moving forward')
  24. steer.rotations(rot, 100, 0)
  25. out('done')
  26. }
  27.  
  28. function b (rot) {
  29. out('moving back')
  30. steer.rotations(-rot, 100, 0)
  31. out('done')
  32. }
  33.  
  34. function l (rot) {
  35. out('turning left')
  36. steer.rotations(1, 100, -rot)
  37. out('done')
  38. }
  39.  
  40. function r (rot) {
  41. out('turning right')
  42. steer.rotations(1, 100, rot)
  43. out('done')
  44. }
  45. function s (rot) {
  46. out('spinning')
  47. steer.rotation(rot, 40, 50)
  48. out('done')
  49. }
  50. function dance (rot) {
  51. out('dancing')
  52. s(4)
  53. f(1)
  54. b(1)
  55. r(45)
  56. out('done')
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement