Skip to main content

Playerlist

Based on game build 714014 | Last updated: 2026-03-08

Overview

PlayerList is a UI widget component responsible for displaying the list of connected players in the lobby screen. It constructs and manages scrollable rows representing each player, including visual elements such as character badges, admin icons, mute toggle buttons, and profile links. It integrates with TheNet to fetch player data and handle network-level actions like muting or viewing profiles.

Usage example

local PlayerList = require "widgets/playerlist"
-- Typically instantiated by the lobby screen, not directly by mods
-- Example override for custom display name logic:
PlayerList.prototype.GetDisplayName = function(self, clientrecord)
return clientrecord.name .. " [" .. (clientrecord.userid or "?") .. "]"
end

Dependencies & tags

Components used: None identified
Tags: Checks tags via inst:HasTag("tag") — None identified
Widgets used: Widget, Text, ImageButton, ScrollableList, PlayerBadge, Image

Properties

PropertyTypeDefault ValueDescription
ownerentityTheNet:GetUserID() equivalentThe local player's user ID; used to determine UI behavior (e.g., disable self-mute).
numPlayersnumber0Cached count of players; used to detect changes requiring full rebuild.
player_widgetstable of widgets{}Array of pre-allocated row widgets reused during refresh.
scroll_listScrollableListnilThe scrollable container managing player rows.
proot, player_list, row_rootwidgetsnilInternal layout containers.

Main functions

GetDisplayName(clientrecord)

  • Description: Returns the display name for a player record. Overridable by mods to customize player name formatting.
  • Parameters: clientrecord (table) — player data object with fields like name, userid, etc.
  • Returns: string — the player's display name (default: clientrecord.name or "").

BuildPlayerList(players, nextWidgets)

  • Description: Builds or rebuilds the entire player list UI. Initializes UI frames and layout if missing, then creates or updates ScrollableList rows.
  • Parameters:
    • players (table or nil) — array of player data tables. If nil, fetches current players via GetPlayerTable().
    • nextWidgets (table) — focus navigation configuration (e.g., right, down widgets).
  • Returns: Nothing.

GetPlayerTable()

  • Description: Retrieves the list of players from TheNet, handling special cases like hosted servers (excludes dedicated host).
  • Parameters: None.
  • Returns: table — array of player data tables. If no players or TheNet unavailable, returns {}.

Refresh(next_widgets)

  • Description: Updates the player list UI efficiently without full rebuild when possible. Rebuilds only if player count changes or identity of players changes.
  • Parameters: next_widgets (table) — focus navigation configuration.
  • Returns: Nothing.

Events & listeners

Listens to: None identified
Pushes: None identified