option

Methods

is_valid

Returns true if the option reference is still valid

function option.is_valid(): bool
-- example usage
local valid = opt:is_valid()

get_label

Returns the label of the option

function option.get_label(): string
-- example usage
local label = opt:get_label()

set_label

Sets the label of the option

function option.set_label(label: string): void
-- example usage
opt:set_label("Example")

get_type

Returns the type of the option

function option.get_type(): string
-- example usage
local type = opt:get_type()

get_toggle

Returns the current state of the toggle associated with the option where applicable

function option.get_toggle(): bool
-- example usage
local state = opt:get_toggle()

set_toggle

Sets the current state associated with the option where applicable

function option.set_toggle(state: bool, save_to_state: bool? --[[false]]): void
-- example usage
opt:set_toggle(false) -- sets the state to false

get_value

Returns the current value associated with the option where applicable

function option.get_value(): float|int|nil
-- example usage
local value = opt:get_value()

set_value

Sets the current value associated with the option where applicable

function option.set_value(value: float|int, save_to_state: bool? --[[false]]): void
-- example usage
opt:set_value(1.0) -- sets the value to 1.0

get_text

Returns the current text associated with the option where applicable

function option.get_text(): string
-- example usage
local text = opt:get_text()

set_text

Sets the current text associated with the option where applicable

function option.set_text(text: string, save_to_state: bool? --[[false]]): void
-- example usage
opt:set_text("Example") -- sets the text to "Example"

get_colour

Returns the current colour associated with the option where applicable

function option.get_colour(): float, float, float, float
-- example usage
local r, g, b, a = opt:get_colour()

set_colour

Sets the current colour associated with the option where applicable

function option.set_colour(red: float, green: float, blue: float, alpha: float, save_to_state: bool? --[[false]]): void
-- example usage
opt:set_colour(1.0, 1.0, 1.0, 1.0) -- sets the colour to 1.0, 1.0, 1.0, 1.0

get_item

Returns the current item associated with the option where applicable

function option.get_item(): string
-- example usage
local item = opt:get_item()

set_item

Sets the current item associated with the option where applicable

function option.set_item(item: string, save_to_state: bool? --[[false]]): void
-- example usage
opt:set_item("Example") -- sets the current item to "Example" if present in the list

add_hint

Adds the provided hint to the option

function option.add_hint(hint: string): void
-- example usage
opt:add_hint("Example")

del_hint

Removes the provided hint from the option

function option.del_hint(hint: string): void
-- example usage
opt:del_hint("Example")