The following get/set various information on per-slot basis.
General
This constant holds the maximum number of player slots in a session.
At the time of writing it's 4
and is somewhat unlikely to change,
but still you can do
for (var p = 0; p < maxp; p++) {
// ...
}
Returns whether the given slot is occupied.
There can be "gaps" in the slot list if someone leaves mid-game.
Returns the numeric "unique ID" of a player controlling the slot.
If two slots have the same UID, they are being controlled from the same computer.
A player that joined the lobby earlier will have a lower UID
than a player that joined (or re-joined) the lobby later,
but otherwise no pattern is guaranteed for these,
and they can have "gaps".
Characters
Returns the current character for a player slot.
These are strings like "fish"
, "robot"
,
or mod names for custom characters.
Returns the current character index for a player slot.
These are numbers like 1 (or char_fish
) for Fish,
5 (or char_robot
) for Robot,
or char_custom
for mods.
All mods share the race index so you'll want to use player_get_race
to tell modded characters apart.
Changes the current character for a player slot.
This accepts both numeric indexes and strings.
Returns whether the specified character exists and was applied.
These are like above, but for what the player has picked on character select screen:
player_get_race_pick(player)➜player_get_race_pick_id(player)➜player_set_race_pick(player, race)
Returns how many players have picked the given character on game start.
Skins
Returns the current skin for a player slot.
This is numeric for base-game skins and strings for modded skins.
Changes the current skin for a player slot.
Returns whether successful.
Visual
Returns the chosen color for a player slot,
as seen in chat, outlines, and player indicators.
Returns the username (or locally set name for offline mode)
of the player controlling the given slot.
This is handy for displaying leaderboards or other UI that addresses the players.
Returns whether the given player has character outlines enabled.
These allow you to hide/show cursors,
markers (the ones placed with digit keys),
and certain UI elements of one player from other player(s).
They are primarily handy for versus mods.
player_get_show_cursor(of_player, to_player)➜player_set_show_cursor(of_player, to_player, show)player_get_show_marker(of_player, to_player)➜player_set_show_marker(of_player, to_player, show)player_get_show_hud(of_player, to_player)➜player_set_show_hud(of_player, to_player, show)player_get_show_prompts(of_player, to_player)player_set_show_prompts(of_player, to_player, show)player_get_show_skills(to_player)➜player_set_show_skills(to_player, show)Non-sync
The following functions aren't subject to synchronization/network latency, thus should only be used for display, else you may cause a desync. See Sync for more information.
Returns whether the given slot is being observed by the local computer.
This is true if the player is local
or if we're spectating the player (either in real-time or on a replay).
Returns whether the given slot is being controlled by the local computer.
Note that spectators have no local slots.
Returns n-th (0-based) local slot index,
or -1 if there are no more local players.
So, if you were occupying P2 and P4, the following
for (var i = 0; i < maxp; i++) {
var p = player_find_local_nonsync(i);
trace(i, p);
if (p < 0) break;
}
would display
0 1 <- P2
1 3 <- P4
2 -1 <- end