Option
User-configurable settings management system for the Lilia framework.
Overview
The option library provides comprehensive functionality for managing user-configurable settings in the Lilia framework. It handles the creation, storage, retrieval, and persistence of various types of options including boolean toggles, numeric sliders, color pickers, text inputs, and dropdown selections. The library operates on both client and server sides, with automatic persistence to JSON files and optional networking capabilities for server-side options. It includes a complete user interface system for displaying and modifying options through the configuration menu, with support for categories, visibility conditions, and real-time updates. The library ensures that all user preferences are maintained across sessions and provides hooks for modules to react to option changes.
lia.option.add(key, name, desc, default, callback, data)
Purpose
Register a configurable option with defaults, callbacks, and metadata.
When Called
During initialization to expose settings to the config UI/system.
Parameters
string key Option identifier to resolve choices for.
string name Display name or localization key.
string desc Description or localization key.
any default Default value; determines inferred type.
function callback optional function(old, new) invoked on change.
table data Extra fields: category, min/max, options, visible, shouldNetwork, isQuick, type, etc.
Example Usage
lia.option.add("hudScale", "HUD Scale", "Scale HUD elements", 1.0, function(old, new)
hook.Run("HUDScaleChanged", old, new)
end, {
category = "Core",
min = 0.5,
max = 1.5,
decimals = 2,
isQuick = true
})
lia.option.getOptions(key)
Purpose
Resolve option choices (static or generated) for dropdowns.
When Called
By the config UI before rendering a Table option.
Parameters
string key
Returns
table Array/map of options.
Example Usage
local list = lia.option.getOptions("weaponSelectorPosition")
for _, opt in pairs(list) do print("Choice:", opt) end