Your init(elevators, building) function receives an array of elevator objects and a building object.
Use methods, properties, and events on each elevator and the building to control the system.
Elevator Methods
elevator.addDestination(...floors)
Append one or more floors to the destination queue. Consecutive duplicates are ignored.
elevator.clearDestination()
Clear all destinations from the queue. The elevator will stop at the next floor and fire 'idle'.
elevator.goToFloor(floorNumber)
Go to a floor immediately — clears the queue and inserts this floor as the sole destination.
elevator.setIndicator(direction)
Set the boarding indicator: "up",
"down",
"any", or
"none".
Controls which waiting passengers board when doors open. Default is "any".
elevator.openDoors()
Request the doors to open. Works when idle (opens immediately) or closing (reverses proportionally).
Ignored while moving.
Elevator Properties
elevator.currentFloor
The floor the elevator is currently at (integer). While moving, this is the last floor it was at.
elevator.destinationQueue
A copy of the current destination queue (array of floor numbers).
elevator.pressedFloors
A copy of floor numbers pressed inside the elevator by passengers (car call buttons).
elevator.passengerCount
Number of passengers currently in the elevator.
elevator.maxPassengerCount
Maximum passenger capacity of the elevator.
elevator.isFull
Boolean — true when the elevator is at capacity.
Elevator Events
Register listeners with elevator.on(event, callback).
'idle'
Fired when the elevator has no pending destinations and is ready for a new command.
elevator.on('idle', () => { ... })
'floor_button_pressed' → (floorNum)
Fired when a passenger inside the elevator presses a car call button for a floor.
We use essential cookies to keep the site running (login, security). With your consent, we also use Google Analytics to understand how visitors use our site — this helps us improve it. We do not sell or share your data with third parties for advertising purposes. Learn more: Privacy Policy.