Defines the client-side cw.character library, which runs the character menu and the character creation process.

It holds the local player's characters and faction whitelists as sent by the server and the creation steps registered with cw.character:RegisterCreationPanel. The rest opens, closes and navigates the character menu panel, and the last creation step sends the CreateCharacter message.

Summary

Methods

Stores a character of the local player.
Fades in the navigation buttons of the character menu, if it exists.
Returns the panel currently shown inside the character menu.
GetAll()client
Returns the local player's characters as sent by the server.
Returns the creation info of the character being created.
Returns the registered character creation steps.
Returns how far the character creation process is.
Returns the last character creation or loading error.
Returns the closest later creation step whose condition passes.
Returns the character menu panel.
Returns the active panel if it is the character list.
Returns the closest earlier creation step whose condition passes.
Returns the factions the local player is whitelisted for.
Returns whether the active character menu panel is a creation step.
Returns whether the server reopened the character menu to reset it.
Returns whether the character menu is waiting for the character list.
Returns whether the character menu is open.
Returns whether the character menu is waiting to open once it has been created.
Returns whether the local player is whitelisted for a faction.
Moves on to the next creation step, or finishes character creation.
Goes back to the previous creation step.
Rebuilds the character list with the local player's characters.
Registers a step of the character creation process.
Removes a step from the character creation process.
Clears the creation info on the character panel, starting a new creation at step 0.
Sets the character error and shows it as cinematic text if it is a string.
Sets whether the character menu is waiting for the character list.
Returns the character menu to its main screen.
Opens or closes the character menu and toggles the mouse cursor to match.
Sets whether the character menu should be opened once it has been created.

Methods

cw.character:Add(characterID, data)

client gamemodes/catwork/gamemode/core/libraries/cl_character.lua:410

Stores a character of the local player.

Parameters

  • characterID Number ID of the character
  • data Character The character data sent by the server

Fades in the navigation buttons of the character menu, if it exists.

Returns the panel currently shown inside the character menu.

Returns

  • Panel The active panel, or nil if there is none or it was removed

Returns the local player's characters as sent by the server.

Returns

  • Map<Character> Character data tables keyed by character ID

Returns the creation info of the character being created.

The index key holds the current step; the steps fill in the other keys (faction, name, model...), which are sent to the server when creation finishes.

Returns

  • Map The creation info stored on the character panel

cw.character:GetCreationPanels()

client gamemodes/catwork/gamemode/core/libraries/cl_character.lua:206

Returns the registered character creation steps.

Returns

  • List<Map> The step info tables, in order

cw.character:GetCreationProgress()

client gamemodes/catwork/gamemode/core/libraries/cl_character.lua:137

Returns how far the character creation process is.

Returns

  • Number Percentage of the registered steps reached, from 0 to 100

Returns the last character creation or loading error.

Returns

  • String The error message, or nil if there is none

cw.character:GetNextCreationPanel()

client gamemodes/catwork/gamemode/core/libraries/cl_character.lua:105

Returns the closest later creation step whose condition passes.

Returns

  • Map The step's info table (index, vguiName, friendlyName, Condition), or nil if the current step is the last

Returns the character menu panel.

Returns

  • Panel The character menu, or nil if it has not been created

Returns the active panel if it is the character list.

Returns

  • Panel The character list panel, or nil if another panel is shown

cw.character:GetPreviousCreationPanel()

client gamemodes/catwork/gamemode/core/libraries/cl_character.lua:86

Returns the closest earlier creation step whose condition passes.

Returns

  • Map The step's info table (index, vguiName, friendlyName, Condition), or nil if there is none

Returns the factions the local player is whitelisted for.

Returns

  • List<String> Faction names, kept up to date by the server

cw.character:IsCreationProcessActive()

client gamemodes/catwork/gamemode/core/libraries/cl_character.lua:143

Returns whether the active character menu panel is a creation step.

Returns

  • Boolean Whether character creation is in progress

Returns whether the server reopened the character menu to reset it.

Returns

  • Boolean Whether the menu was reset, or nil if it never was

Returns whether the character menu is waiting for the character list.

Returns

  • Boolean Whether the menu is loading

Returns whether the character menu is open.

Returns

  • Boolean Whether the menu is open

Returns whether the character menu is waiting to open once it has been created.

Returns

  • Boolean Whether the menu is waiting to open

cw.character:IsWhitelisted(faction)

client gamemodes/catwork/gamemode/core/libraries/cl_character.lua:249

Returns whether the local player is whitelisted for a faction.

Parameters

  • faction String Name of the faction

Returns

  • Boolean Whether the player is whitelisted

cw.character:OpenNextCreationPanel()

client gamemodes/catwork/gamemode/core/libraries/cl_character.lua:181

Moves on to the next creation step, or finishes character creation.

The active step's OnNext method can return false to stay on it. After the last step it runs the PlayerAdjustCharacterCreationInfo hook and sends the creation info to the server to create the character.

See also

cw.character:OpenPreviousCreationPanel()

client gamemodes/catwork/gamemode/core/libraries/cl_character.lua:158

Goes back to the previous creation step.

The active step's OnPrevious method can return false to stay on it. Does nothing on the first step.

See also

Rebuilds the character list with the local player's characters.

Characters are grouped with the GetPlayerCharacterScreenFaction hook, sorted within a group with CharacterScreenSortFactionCharacters and the groups are sorted by name. Does nothing when the character list is not shown.

cw.character:RegisterCreationPanel(friendlyName, vguiName, index, Condition)

client gamemodes/catwork/gamemode/core/libraries/cl_character.lua:32

Registers a step of the character creation process.

A step whose friendly name is already registered is ignored, so the call is safe on auto-refresh. When index is given, the steps at or after it move down one place.

cw.character:RegisterCreationPanel('#CharCreation_DefaultClass', 'cw.characterStageThree', nil,
  function(info)
    return info.faction == 'Citizen'
  end
)

Parameters

  • friendlyName String Name of the step, usually a language phrase
  • vguiName String Name of the VGUI panel class opened for the step
  • index Number optional, defaults to nil Position of the step; appended to the end when nil
  • Condition Function optional, defaults to nil Called with the creation info Map when moving between steps; return false to skip the step

See also

cw.character:RemoveCreationPanel(name)

client gamemodes/catwork/gamemode/core/libraries/cl_character.lua:61

Removes a step from the character creation process.

The steps after it move up one place.

Parameters

  • name String VGUI panel class or friendly name of the step

See also

cw.character:ResetCreationInfo()

client gamemodes/catwork/gamemode/core/libraries/cl_character.lua:122

Clears the creation info on the character panel, starting a new creation at step 0.

Sets the character error and shows it as cinematic text if it is a string.

Parameters

  • fault String The error message, or a language phrase; nil clears it

cw.character:SetPanelLoading(loading)

client gamemodes/catwork/gamemode/core/libraries/cl_character.lua:220

Sets whether the character menu is waiting for the character list.

Parameters

  • loading Boolean Whether the menu is loading

Returns the character menu to its main screen.

cw.character:SetPanelOpen(open, bReset)

client gamemodes/catwork/gamemode/core/libraries/cl_character.lua:383

Opens or closes the character menu and toggles the mouse cursor to match.

When the menu does not exist yet, opening it marks it as polling so it opens once it has been created.

Parameters

  • open Boolean Whether to open the menu
  • bReset Boolean optional, defaults to nil When closing, keep the menu marked open and visible

cw.character:SetPanelPolling(polling)

client gamemodes/catwork/gamemode/core/libraries/cl_character.lua:361

Sets whether the character menu should be opened once it has been created.

Parameters

  • polling Boolean Whether the menu is waiting to open

Defined in