Registers the types of settings that come with the Settings plugin: 'boolean', 'number', 'choice' and 'string'. Each of them checks the values of its settings on both realms and creates the control that edits such a setting in the settings menu on the client.
Summary
Functions
Functions
create_control(_setting, parent, value, on_change)
shared plugins/settings/plugin/lib/sh_types.lua:27Creates a switch that turns the setting on and off. Clientside only.
Parameters
- _setting Map setting definition
- parent Panel row of the settings menu to create the control in
- value Boolean current value of the setting
- on_change Function called with the new value when the switch is clicked
Returns
- Panel the created fl_button
create_control(setting, parent, value, on_change)
shared plugins/settings/plugin/lib/sh_types.lua:86Creates a slider over the range of the setting. Clientside only. A new DNumSlider holds 0.5 and ignores being set to the value it already holds, so the slider is told that its value has changed either way; otherwise a setting that is at 0.5 would keep the knob and the text of the slider's initial range of 0 to 1.
Parameters
- setting Map setting definition
- parent Panel row of the settings menu to create the control in
- value Number current value of the setting
- on_change Function called with the new value while the slider is moved
Returns
- Panel the created DNumSlider
create_control(setting, parent, value, on_change)
shared plugins/settings/plugin/lib/sh_types.lua:160Creates a dropdown that lists the choices of the setting. Clientside only. The dropdown keeps the position of every choice instead of its value, since DComboBox drops a value of false.
Parameters
- setting Map setting definition
- parent Panel row of the settings menu to create the control in
- value Any current value of the setting
- on_change Function called with the value of the choice that is picked
Returns
- Panel the created DComboBox
create_control(setting, parent, value, on_change)
shared plugins/settings/plugin/lib/sh_types.lua:212Creates a text entry limited to the maximum length of the setting. Clientside only.
Parameters
- setting Map setting definition
- parent Panel row of the settings menu to create the control in
- value String current value of the setting
- on_change Function called with the new text whenever the player edits it
Returns
- Panel the created fl_text_entry
Returns the default of a boolean setting that does not define one.
Parameters
- _setting Map setting definition
Returns
- Boolean false
Returns the default of a number setting that does not define one: its minimum.
Parameters
- setting Map setting definition
Returns
- Number
Returns the default of a choice setting that does not define one: its first choice.
Parameters
- setting Map setting definition
Returns
- Any value of the first choice
Returns the default of a string setting that does not define one.
Parameters
- _setting Map setting definition
Returns
- String an empty string
Accepts booleans only.
Parameters
- _setting Map setting definition
- value Any value to check
Returns
- Boolean the value, or nil if it is not a boolean
Accepts numbers, clamped to the range of the setting and rounded to its decimals.
Parameters
- setting Map setting definition
- value Any value to check
Returns
- Number the corrected value, or nil if it is not a number
Accepts the values of the choices of the setting only.
Parameters
- setting Map setting definition
- value Any value to check
Returns
- Any the value, or nil if it is not one of the choices
Accepts strings of valid UTF-8 that are not longer than the setting allows.
Parameters
- setting Map setting definition
- value Any value to check
Returns
- String the value, or nil if it is not such a string
Fills in the range and the precision of a number setting: 0 to 100 without decimals unless the setting says otherwise.
Parameters
- setting Map setting definition
Returns
- Boolean false if the range is not valid, nothing otherwise
Turns the choices of the setting into a list of { value, name } tables. A choice that is given as a plain value is named after that value.
Parameters
- setting Map setting definition
Returns
- Boolean false if the setting has no choices, nothing otherwise
Fills in the maximum length of a string setting: 128 characters unless the setting says otherwise.
Parameters
- setting Map setting definition