Configuration¶
Configuration helpers for registering, retrieving, localizing, synchronizing, saving, and editing Lilia configuration values.
Overview
lia.config.add(key, name, value, callback, data)View Source
Purpose
Registers a configuration entry and stores its metadata, default value, current value, localization data, optional callback, and UI behavior.
Realm
Shared
Parameters
string key The unique configuration key.
string name The display name or localization token shown for the configuration.
any value The default value for the configuration.
function callback optional Optional function called with the old value and new value when the configuration is changed through `lia.config.set` or reset on the server.
table data Configuration metadata, including fields such as type, desc, category, min, max, decimals, options, optionsFunc, noNetworking, isGlobal, and uniqueTab.
Example Usage
lia.config.add("ExampleEnabled", "@exampleEnabled", true, nil, {
desc = "@exampleEnabledDesc",
category = "@core",
type = "Boolean"
})
lia.config.getDisplayName(key)View Source
Purpose
Returns the localized display name for a registered configuration key.
Realm
Shared
Parameters
string key The configuration key whose display name should be returned.
Returns
string|any The localized display name when available, or the key when the configuration is not registered.
Example Usage
print(lia.config.getDisplayName("WalkSpeed"))
lia.config.getDisplayDesc(key)View Source
Purpose
Returns the localized description for a registered configuration key.
Realm
Shared
Parameters
string key The configuration key whose description should be returned.
Returns
string|any The localized description when available, or an empty string when the configuration is not registered.
Example Usage
print(lia.config.getDisplayDesc("WalkSpeed"))
lia.config.getDisplayCategory(key)View Source
Purpose
Returns the localized category for a registered configuration key.
Realm
Shared
Parameters
string key The configuration key whose category should be returned.
Returns
string|any The localized category when available, or the localized character category when the configuration is not registered.
Example Usage
print(lia.config.getDisplayCategory("WalkSpeed"))
lia.config.getOptions(key)View Source
Purpose
Returns normalized selectable options for a registered table-based configuration.
Realm
Shared
Parameters
string key The configuration key whose options should be returned.
Returns
table A table of normalized option entries containing rawLabel, localized label, and value fields. Returns an empty table when no options are available.
Example Usage
for _, option in pairs(lia.config.getOptions("Language")) do
print(option.label, option.value)
end
lia.config.setDefault(key, value)View Source
lia.config.forceSet(key, value, noSave)View Source
Purpose
Directly changes a registered configuration value, runs the update hook, and optionally saves the configuration without type coercion, networking, or callbacks.
Realm
Shared
Parameters
string key The configuration key to change.
any value The value to assign.
boolean noSave optional When true, prevents the configuration from being saved after the value is changed.
Example Usage
lia.config.forceSet("WalkSpeed", 250, true)
lia.config.set(key, value)View Source
Purpose
Changes a registered configuration value, coerces it to the expected type, runs update hooks, broadcasts the value from the server when networking is enabled, calls the configuration callback, and saves the configuration.
Realm
Shared
Parameters
Example Usage
lia.config.set("WalkSpeed", 250)
lia.config.get(key, default)View Source
Purpose
Returns the current value for a registered configuration key, falling back to its default value or the provided fallback.
Realm
Shared
Parameters
string key The configuration key to read.
any default Optional fallback value returned when the configuration key is not registered or has no stored value.
Returns
any The current configuration value, its default value, the special client color fallback for `Color`, or the provided fallback.
Example Usage
local walkSpeed = lia.config.get("WalkSpeed", 200)
lia.config.load()View Source
lia.config.getChangedValues(includeDefaults)View Source
Purpose
Builds a table of configuration values that differ from their defaults or from the last values synchronized to clients.
Realm
Server
Parameters
boolean includeDefaults optional When true, compares each current value against its default instead of the last synchronized value.
Returns
table A table of changed configuration keys and normalized values.
Example Usage
local changes = lia.config.getChangedValues()
lia.config.send(client)View Source
Purpose
Sends configuration data to one client or broadcasts changed configuration values to all human players.
Realm
Server
Parameters
Player client optional Optional player who should receive the full saved configuration table. When omitted, changed values are sent to all human players.
Example Usage
lia.config.send(client)
lia.config.send()
lia.config.save()View Source
lia.config.reset()View Source
Hooks
Library-specific hooks documented for this library.
CanPlayerModifyConfig(client, key)View Source
Purpose
Allows plugins or modules to control whether a player may view or modify configuration values.
Category
Configuration
Realm
Shared
Parameters
Player client The player attempting to access or modify configuration values.
string key The configuration key being modified. This argument is only provided during a configuration change.
Returns
boolean|nil Return false to block access or modification. Return nil or true to allow it.
Example Usage
hook.Add("CanPlayerModifyConfig", "liaExampleCanPlayerModifyConfig", function(client, key)
if IsValid(client) and client:IsAdmin() then
return true
end
end)
ConfigChanged(key, newValue, oldValue, client)View Source
Purpose
Runs on the server after a player successfully changes a configuration value.
Category
Configuration
Realm
Server
Parameters
string key The configuration key that changed.
any newValue The new value assigned to the configuration key.
any oldValue The previous value for the configuration key.
Player client The player who changed the configuration value.
Example Usage
hook.Add("ConfigChanged", "liaExampleConfigChanged", function(key, newValue, oldValue, client)
if not IsValid(client) then return end
print(string.format("[MyModule] handled ConfigChanged for %s", client:Name()))
end)
CreateSalaryTimers()View Source
DermaSkinChanged(skin)View Source
Purpose
Runs when the `DermaSkin` configuration value changes.
Category
Configuration
Realm
Shared
Parameters
string skin The selected Derma skin name.
Example Usage
hook.Add("DermaSkinChanged", "liaExampleDermaSkinChanged", function(skin)
print("[MyModule] handled DermaSkinChanged")
end)
InitializedConfig()View Source
OnConfigUpdated(key, oldValue, newValue)View Source
Purpose
Runs whenever a configuration value is updated locally through `lia.config.set`, `lia.config.forceSet`, or a networked configuration update.
Category
Configuration
Realm
Shared
Parameters
string key The configuration key that changed.
any oldValue The previous value for the configuration key.
any newValue The new value for the configuration key.
Example Usage
hook.Add("OnConfigUpdated", "liaExampleOnConfigUpdated", function(key, oldValue, newValue)
print("[MyModule] handled OnConfigUpdated")
end)
VoiceToggled(enabled)View Source
Purpose
Runs when the `IsVoiceEnabled` configuration value changes.
Category
Configuration
Realm
Shared
Parameters
boolean enabled True when voice chat is enabled, false when it is disabled.
Example Usage
hook.Add("VoiceToggled", "liaExampleVoiceToggled", function(enabled)
print("[MyModule] handled VoiceToggled")
end)