Advertisement
Guest User

Untitled

a guest
Jan 26th, 2015
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. {
  2. init: function(elevators, floors) {
  3. var elevator = elevators[0]; // Let's use the first elevator
  4. var floor = floors;
  5. elevator.on("idle", function() {
  6. elevator.goToFloor(0);
  7. elevator.checkDestinationQueue();
  8. elevator.goToFloor(elevator.destinationQueue[0]);
  9. });
  10.  
  11. elevator.on("floor_button_pressed", function(floorNum){
  12. elevator.destinationQueue.push(floorNum);
  13. elevator.destinationQueue.sort();
  14. elevator.goToFloor(elevator.destinationQueue[0]);
  15. })
  16.  
  17. },
  18. update: function(dt, elevators, floors) {
  19. // We normally don't need to do anything here
  20. }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement