Advertisement
Guest User

Untitled

a guest
Jul 7th, 2013
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.  * The round switches won't stay on unless something is placed on top of them.
  3.  */
  4.  
  5. r = this;
  6.  
  7. all_off = function() {
  8.   r.thrusters.top(false);
  9.   r.thrusters.bottom(false);
  10.   r.thrusters.left(false);
  11.   r.thrusters.right(false);
  12. }
  13.  
  14. var step = 0, call = 0;
  15.  
  16. sw = function(sensor, on, check, cb) {
  17.   var this_step = call;
  18.   call = call + 1;
  19.   r.on("sensor:" + sensor, function(c) {
  20.     if (c == check && step == this_step) {
  21.         step = step + 1;
  22.         all_off()  
  23.         r.thrusters[on](true);
  24.         if (cb) cb();
  25.     }
  26.   });
  27. }
  28.  
  29. r.on("start", function() {r.thrusters.bottom(true); });
  30.  
  31. sw("top", "left", true);
  32. sw("right", "top", true);
  33. sw("left", "left", true);
  34. sw("right", "top", true);
  35. sw("bottom", "left", true);
  36. sw("right", "bottom", true);
  37. sw("left", "left", true);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement