Configuration
Comprehensive user-configurable settings management system for the Lilia framework.
Overview
lia.config.add(key, name, value, callback, data)
Purpose
Register a config entry with defaults, UI metadata, and optional callback.
When Called
During schema/module initialization to expose server-stored configuration.
Parameters
string key Unique identifier for the config entry.
string name Display text or localization key for UI.
any value Default value; type inferred when data.type is omitted.
function callback optional Invoked server-side as callback(oldValue, newValue) after set().
table data Fields such as type, desc, category, options/optionsFunc, noNetworking, etc.
Example Usage
lia.config.add("MaxThirdPersonDistance", "maxThirdPersonDistance", 100, function(old, new)
lia.option.set("thirdPersonDistance", math.min(lia.option.get("thirdPersonDistance", new), new))
end, {category = "Lilia", type = "Int", min = 10, max = 200})
lia.config.getDisplayName(key)
Purpose
Retrieve the localized display name of a config entry.
When Called
When rendering config entries in the UI or when a human-readable name is needed.
Parameters
string key The config key to look up.
Returns
string Localized display name, or the raw key if the entry does not exist.
Example Usage
local name = lia.config.getDisplayName("MaxCarryWeight")
print("Config name:", name)
lia.config.getDisplayDesc(key)
Purpose
Retrieve the localized description of a config entry.
When Called
When populating tooltips or description fields in the config UI.
Parameters
string key The config key to look up.
Returns
string Localized description string, or an empty string if none exists.
Example Usage
local desc = lia.config.getDisplayDesc("MaxCarryWeight")
print("Config description:", desc)
lia.config.getDisplayCategory(key)
Purpose
Retrieve the localized category of a config entry for grouping in the UI.
When Called
When building the config UI to sort entries into category sections.
Parameters
string key The config key to look up.
Returns
string Localized category name, or "character" as the default fallback.
Example Usage
local cat = lia.config.getDisplayCategory("MaxCarryWeight")
print("Config category:", cat)
lia.config.getOptions(key)
Purpose
Resolve a config entry's selectable options, static list or generated.
When Called
Before rendering dropdown-type configs or validating submitted values.
Parameters
string key Config key to resolve options for.
Returns
table Options array or key/value table; empty when unavailable.
Example Usage
local opts = lia.config.getOptions("Theme")
lia.config.forceSet(key, value, noSave)
Purpose
Force-set a config value and fire update hooks without networking.
When Called
Runtime adjustments (admin tools/commands) or hot reload scenarios.
Parameters
string key Config key to change.
any value Value to assign.
boolean noSave optional When true, skip persisting to disk.
Example Usage
lia.config.forceSet("MaxCharacters", 10, false)
lia.config.set(key, value)
lia.config.get(key, default)
Purpose
Retrieve a config value with fallback to its stored default or a provided default.
When Called
Anywhere configuration influences gameplay or UI logic.
Parameters
string key Config key to read.
any default Optional fallback when no stored value or default exists.
Returns
any Stored value, default value, or supplied fallback.
Example Usage
local walkSpeed = lia.config.get("WalkSpeed", 200)
lia.config.getChangedValues(includeDefaults)
Purpose
Get all configuration values that have been changed from their defaults.
When Called
During config synchronization to determine what needs to be sent to clients.
Parameters
boolean includeDefaults When true, includes all values even if they match defaults.
Returns
table Key/value pairs of changed configuration entries.
Example Usage
local changes = lia.config.getChangedValues()
lia.config.send(client)
Purpose
Send configuration data to a specific client or all clients.
When Called
During initial connection or when config values change.
Parameters
Player client optional Specific client to send to, or nil for all clients.
Example Usage
lia.config.send() -- Send to all clients
lia.config.send(client) -- Send to specific client