cw.character classclient
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
Methods
cw.character:Add(characterID, data)
client gamemodes/catwork/gamemode/core/libraries/cl_character.lua:410Stores a character of the local player.
Parameters
- characterID Number ID of the character
- data Character The character data sent by the server
Returns the panel currently shown inside the character menu.
Returns
- Panel The active panel, or
nilif 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
cw.character:GetCreationInfo()
client gamemodes/catwork/gamemode/core/libraries/cl_character.lua:131Returns 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:206Returns 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:137Returns 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
nilif there is none
cw.character:GetNextCreationPanel()
client gamemodes/catwork/gamemode/core/libraries/cl_character.lua:105Returns the closest later creation step whose condition passes.
Returns
- Map The step's info table (
index,vguiName,friendlyName,Condition), ornilif the current step is the last
Returns the character menu panel.
Returns
- Panel The character menu, or
nilif it has not been created
Returns the active panel if it is the character list.
Returns
- Panel The character list panel, or
nilif another panel is shown
cw.character:GetPreviousCreationPanel()
client gamemodes/catwork/gamemode/core/libraries/cl_character.lua:86Returns the closest earlier creation step whose condition passes.
Returns
- Map The step's info table (
index,vguiName,friendlyName,Condition), ornilif 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:143Returns 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
nilif 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:249Returns 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:181Moves 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:158Goes 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
cw.character:RefreshPanelList()
client gamemodes/catwork/gamemode/core/libraries/cl_character.lua:295Rebuilds 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:32Registers 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
nilPosition of the step; appended to the end whennil - Condition Function optional, defaults to
nilCalled with the creation infoMapwhen moving between steps; returnfalseto skip the step
See also
cw.character:RemoveCreationPanel(name)
client gamemodes/catwork/gamemode/core/libraries/cl_character.lua:61Removes 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:122Clears 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;
nilclears it
cw.character:SetPanelLoading(loading)
client gamemodes/catwork/gamemode/core/libraries/cl_character.lua:220Sets whether the character menu is waiting for the character list.
Parameters
- loading Boolean Whether the menu is loading
cw.character:SetPanelMainMenu()
client gamemodes/catwork/gamemode/core/libraries/cl_character.lua:351Returns the character menu to its main screen.
cw.character:SetPanelOpen(open, bReset)
client gamemodes/catwork/gamemode/core/libraries/cl_character.lua:383Opens 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
nilWhen closing, keep the menu marked open and visible
cw.character:SetPanelPolling(polling)
client gamemodes/catwork/gamemode/core/libraries/cl_character.lua:361Sets whether the character menu should be opened once it has been created.
Parameters
- polling Boolean Whether the menu is waiting to open