lia.option
The lia.option
module manages user-specific options within your schema. It allows clients to define, retrieve, and persist various option settings tailored to individual players. Options can have different data types such as booleans, numbers, colors, and generic text fields. Additionally, options support callbacks for reacting to changes and can be categorized for better organization.
lia.option.add
Description:
Adds a new option to the system.
Realm:
Client
Parameters:
key
(string
): The unique identifier for the option.name
(string
): The display name of the option.desc
(string
): A description of what the option does.default
(any
): The default value of the option.callback
(function
, optional): A function to call when the option value changes.data
(table
): A table containing additional data for the option.min
(number
, optional): The minimum value for numerical options. Defaults to half of the default forInt
andFloat
types.max
(number
, optional): The maximum value for numerical options. Defaults to double the default forInt
andFloat
types.
Option Types:
"Boolean"
: A true/false option."Int"
: An integer option."Float"
: A floating-point number option."Color"
: A color option withr
,g
, andb
values."Generic"
: A text field.
Usage Example:
-- Adding a new option on the client side
lia.option.add("ShowHUD", "Show HUD", "Toggle the visibility of the HUD.", true, nil, {
})
lia.option.set
Description:
Sets the value of an existing option and handles callbacks and saving.
Realm:
Client
Parameters:
key
(string
): The unique identifier of the option.value
(any
): The new value to set for the option.
Usage Example:
lia.option.get
Description:
Retrieves the current value of an option, falling back to the default if not set.
Realm:
Client
Parameters:
key
(string
): The unique identifier of the option.default
(any
, optional): The default value to return if the option is not set.
Returns:
any
: The current value of the option or the default value.
Usage Example:
lia.option.save
Description:
Saves all current option values to persistent storage based on the client's IP and active gamemode.
Realm:
Client
Usage Example:
lia.option.load
Description:
Loads all option values from persistent storage. If no saved options are found, it saves the current options as defaults.
Realm:
Client
Usage Example: