Methods
convertDeviceIdToPlayerNumber(device_id) → {number|undefined}
Returns the player number for a device_id, if the device_id is part of the
active players previously set by the screen by calling setActivePlayers.
Player numbers are zero based and are consecutive. If the device_id is not
part of the active players, this function returns undefined.
Parameters:
Name | Type | Description |
---|---|---|
device_id |
- Source:
Returns:
- Type
- number | undefined
convertPlayerNumberToDeviceId(player_number) → {number|undefined}
Returns the device_id of a player, if the player is part of the active
players previously set by the screen by calling setActivePlayers. If fewer
players are in the game than the passed in player_number or the active
players have not been set by the screen, this function returns undefined.
Parameters:
Name | Type | Description |
---|---|---|
player_number |
- Source:
Returns:
- Type
- number | undefined
getActivePlayerDeviceIds() → {Array}
Returns an array of device_ids of the active players previously set by the
screen by calling setActivePlayers. The first device_id in the array is the
first player, the second device_id in the array is the second player, ...
- Source:
Returns:
- Type
- Array
(abstract) onActivePlayersChange(player_number)
Gets called when the screen sets the active players by calling
setActivePlayers().
Parameters:
Name | Type | Description |
---|---|---|
player_number |
number | undefined | The player number of this device. Can be undefined if this device is not part of the active players. |
- Source:
setActivePlayers(max_players)
Takes all currently connected controllers and assigns them a player number.
Can only be called by the screen. You don't have to use this helper function, but this mechanism is very convenient if you want to know which device is the first player, the second player, the third player ...
The assigned player numbers always start with 0 and are consecutive. You can hardcode player numbers, but not device_ids.
Once the screen has called setActivePlayers you can get the device_id of the first player by calling convertPlayerNumberToDeviceId(0), the device_id of the second player by calling convertPlayerNumberToDeviceId(1), ...
You can also convert device_ids to player numbers by calling convertDeviceIdToPlayerNumber(device_id). You can get all device_ids that are active players by calling getActivePlayerDeviceIds().
The screen can call this function every time a game round starts.
When using Player Silencing, the screen needs to call this every time a game round starts or finishes.
Calling it with max_players of 1 or more signals the start of the game round while calling it with max_players 0 signals the end of the game round.
Can only be called by the screen. You don't have to use this helper function, but this mechanism is very convenient if you want to know which device is the first player, the second player, the third player ...
The assigned player numbers always start with 0 and are consecutive. You can hardcode player numbers, but not device_ids.
Once the screen has called setActivePlayers you can get the device_id of the first player by calling convertPlayerNumberToDeviceId(0), the device_id of the second player by calling convertPlayerNumberToDeviceId(1), ...
You can also convert device_ids to player numbers by calling convertDeviceIdToPlayerNumber(device_id). You can get all device_ids that are active players by calling getActivePlayerDeviceIds().
The screen can call this function every time a game round starts.
When using Player Silencing, the screen needs to call this every time a game round starts or finishes.
Calling it with max_players of 1 or more signals the start of the game round while calling it with max_players 0 signals the end of the game round.
Parameters:
Name | Type | Description |
---|---|---|
max_players |
number | The maximum number of controllers that should get a player number assigned. |
- Source: