Consolescreensettings
Based on game build 714014 | Last updated: 2026-03-10
Overview
ConsoleScreenSettings handles persistent configuration and history for the in-game console screen. It stores command history (up to MAX_SAVED_COMMANDS entries) and word prediction widget state in persistent storage, and provides methods to load, save, and manipulate this data. It is used exclusively on the client for UI state management and does not interact with server-side entities or replication.
Usage example
local settings = ConsoleScreenSettings()
settings:Load()
-- Add a command to history
settings:AddLastExecutedCommand("c_give(master, 'log')", false)
-- Check and set word prediction state
if not settings:IsWordPredictionWidgetExpanded() then
settings:SetWordPredictionWidgetExpanded(true)
end
-- Persist changes to disk
settings:Save()
Dependencies & tags
Components used: None
Tags: None identified.
Properties
| Property | Type | Default Value | Description |
|---|---|---|---|
persistdata | table | {} | Internal dictionary storing all persisted settings (e.g., "historylines", "expanded"). |
profanityservers | table | {} | Reserved placeholder; unused in current implementation. |
dirty | boolean | true | Flag indicating whether unsaved changes exist. |
Main functions
Reset()
- Description: Clears all persistent settings, marks the instance as dirty, and triggers an immediate save.
- Parameters: None.
- Returns: Nothing.
GetConsoleHistory()
- Description: Returns the current list of saved console command history lines.
- Parameters: None.
- Returns:
{ { str = string, remote = boolean }, ... }— list of command entries; each entry containsstr(command text) andremote(execution context flag). Returns empty array if none exist.
AddLastExecutedCommand(command_str, toggle_remote_execute)
- Description: Adds a command to the history if not empty or a repeat of
c_repeatlastcommand(). Ensures no duplicate entries and maintains maxMAX_SAVED_COMMANDSitems by shifting duplicates to the end and removing oldest entries as needed. - Parameters:
command_str(string) — The console command string to add.toggle_remote_execute(boolean or nil) — Whether the command should be executed remotely. Converted totrueornil.
- Returns: Nothing.
- Error states: Does nothing if
command_stris empty or exactly"c_repeatlastcommand()".
IsWordPredictionWidgetExpanded()
- Description: Checks whether the word prediction widget UI is currently expanded.
- Parameters: None.
- Returns:
boolean—trueif expanded, otherwisefalse.
SetWordPredictionWidgetExpanded(value)
- Description: Sets the expanded state of the word prediction widget.
- Parameters:
value(boolean) — The new expanded state. - Returns: Nothing.
GetSaveName()
- Description: Returns the persistent storage key used for saving/loading.
- Parameters: None.
- Returns:
string—"consolescreen"for non-dev builds;"consolescreen_"..BRANCHfor dev builds.
Save(callback)
- Description: Serializes
persistdatato JSON and writes it to persistent storage ifdirtyistrue. Callscallbackupon completion. - Parameters:
callback(function or nil) — Optional function receiving(success: boolean)as argument. - Returns: Nothing directly;
callbackreceives success status.
Load(callback)
- Description: Initiates loading of saved settings from persistent storage using
TheSim:GetPersistentString. - Parameters:
callback(function or nil) — Optional function receiving(success: boolean)as argument. - Returns: Nothing.
OnLoad(str, callback)
- Description: Handles loaded string data: decodes JSON, migrates legacy
"history"/"localremotehistory"keys to new"historylines"format, and callscallback. - Parameters:
str(string) — Raw persistent string from disk.callback(function or nil) — Optional function receiving(success: boolean)as argument.
- Returns: Nothing.
Events & listeners
None identified.