Skip to content

Configuration

Configuration helpers for registering, retrieving, localizing, synchronizing, saving, and editing Lilia configuration values.


Overview

The configuration library centralizes runtime settings under `lia.config`. It stores registered configuration definitions, preserves defaults, localizes names, descriptions, categories, and selectable options, coerces networked values into the expected types, synchronizes changed server values to clients, persists non-default values, and builds the client configuration menu.

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

Purpose

Updates the default value for a registered configuration key.

Realm

Shared

Parameters

string key The configuration key whose default value should be changed.

any value The new default value.

Example Usage

  lia.config.setDefault("WalkSpeed", 200)

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

string key The configuration key to change.

any value The value to assign.

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

Purpose

Loads saved configuration values from data storage, applies defaults for missing values, updates the last-synced value cache, and runs the initialization hook.

Realm

Server

Example Usage

  lia.config.load()

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

Purpose

Persists all registered configuration values that differ from their defaults.

Realm

Server

Example Usage

  lia.config.save()

lia.config.reset()View Source

Purpose

Resets every registered configuration value to its default, runs configuration callbacks, saves the new state, and synchronizes clients.

Realm

Server

Example Usage

  lia.config.reset()

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.

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.


ConfigChanged(key, newValue, oldValue, client)View Source

Purpose

Runs on the server after a player successfully changes a configuration value.

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.


CreateMenuButtons(tabs)View Source

Purpose

Allows menu tabs to be collected for the `DefaultMenuTab` configuration option.

Realm

Client

Parameters

table tabs A table that should be populated with menu tab definitions.


CreateSalaryTimers()View Source

Purpose

Runs shortly after the `SalaryInterval` configuration value changes so salary timers can be rebuilt.

Realm

Server


DermaSkinChanged(skin)View Source

Purpose

Runs when the `DermaSkin` configuration value changes.

Realm

Shared

Parameters

string skin The selected Derma skin name.


InitializedConfig()View Source

Purpose

Runs after configuration values have been loaded on the server or received by the client.

Realm

Shared


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.

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.


VoiceToggled(enabled)View Source

Purpose

Runs when the `IsVoiceEnabled` configuration value changes.

Realm

Shared

Parameters

boolean enabled True when voice chat is enabled, false when it is disabled.