Skip to main content

Users

FetchLeaderboard

await FetchLeaderboard(fields, limit?=) -> array
warning

This function is only available from within a page. If called inside a game, it will just return an empty Array.

Returns a ranked leaderboard representing the top players in the game for a particular set of Accumulators.

Parameters:

  • fields (an Array of Accumulators): the Accumulators to fetch. The leaderboard entries will be sorted from highest-to-lowest by the first Accumulator in fields, then the remaining Accumulators will be used as tiebreakers if necessary.
  • limit (Number): the maximum number of entries to return. The limit is capped at 100 (the default).

Returns an Array representing the top limit entries from the leaderboard. Each element in the Array will be a Map with the following key-value pairs:

  • UserId: a string representing the player's unique identifier.
  • PlayerName: a string representing the player's display name.
  • Each accumulator in accumulators: a number representing the player's score in that Accumulator.

FetchUserAccumulators

await FetchUserAccumulators([userId]) -> profile
warning

This function is only available from within a page. If called inside a game, it will just return an empty Map.

Returns a Map representing the user's profile. The Map will have the following key-value pairs:

  • UserId: a string representing the user's unique identifier.
  • PlayerName: a string representing the user's display name.
  • Each Accumulator: a number representing the user's score in that Accumulator. All available accumulators will be retrieved. If the user does not have a value for this Accumulator yet, reading it will return its initial value, which can be customized but defaults to 0.

If userId is nullish or no user exists with the given ID, returns undefined.

IsUserLoggedIn

owner.IsUserLoggedIn -> boolean

Returns whether the owner player represents a user who is logged in or not. Returned undefined if owner is nullish.

LoginIntent

LoginIntent -> intent

Returns an intent to log in. The intent can be attached to a button to trigger the login process. Logging in will force the player to leave the current game or page in order to follow the login process.

Example:

Toolbar {
Button(LoginIntent) { "Login" }
}

LogoutIntent

LogoutIntent -> intent

Returns an intent to log out. The intent can be attached to a button to trigger the logout process. Logging out will force the player to leave the current game or page in order to follow the logout process.

Example:

Toolbar {
Button(LogoutIntent) { "Logout" }
}

ManageAccountIntent

ManageAccountIntent -> intent

Returns an intent to go to the account management page. The intent can be attached to a button to trigger it. Going to the account management page will force the player to leave the current game or page.

OnlinePlayerScoreboard

OnlinePlayerScoreboard(accumulator, [ui=])

Add a live scoreboard to the user interface. Unlike Scoreboard, this scoreboard will include all players currently online. This could be used to display who has achieved the most wins recently, for example.

  • accumulator (Accumulator): the property or accumulator to rank players by. This would normally be an Accumulator.
  • ui (UI): The user interface slot to which the scoreboard should be added.

Example:

pub accumulator owner.NumLifetimeWins = 0

pub fn World.Example1() {
StatusContent {
GlobalScoreboard(&NumLifetimeWins)
}
}

Scoreboard

Scoreboard(propOrAccumulator, [ui=])

Add a live scoreboard to the user interface. This scoreboard will include all players in the current game, ranked by the given Prop or Accumulator indicated by propOrAccumulator. For a player to appear in the scoreboard, you must first set their respective Prop or Accumulator to a value.

This could be used to display who has shot down the most enemies, collected the most eggs, has the most points, for example.

  • propOrAccumulator (Accumulator): the property or accumulator to rank players by.
  • ui (UI): The user interface slot to which the scoreboard should be added.

Example:

pub prop owner.Score = 0

pub fn World.Main() {
SpawnEachPlayer owner {
owner.Score = 0 // must set the property once to appear on the scoreboard
}
}

pub fn World.Example1() {
StatusContent {
Scoreboard(&Score)
}
}

UserId

owner.UserId -> string

Returns a String containing the unique user ID for the owner. All human players will have a user ID, even if they are not logged in. If the player is a bot, they will not have returns null. If owner is nullish or not a player Entity, returns undefined.

Username

owner.Username -> string

Returns the username that has been registered to the owner player. If the player does not have a username, returns undefined. Usernames are globally unique across the Easel platform, and have to be specifically registered by the user, and so most players will not have a username. You can help your players register a username by giving them a link to the Manage Account page by creating a button with a ManageAccountIntent.

Returns undefined if owner is nullish or not a player entity.