Skip to content

Option functions

register_option_bool

documented onlysource

register_option_bool("bomb_bag", "BombBag", "Spawn bomb bag at the start of every level", false)
set_callback(function()
if options.bomb_bag then
-- Spawn the bomb bag at player location thanks to the LAYER.PLAYER1
spawn_entity_snapped_to_floor(ENT_TYPE.ITEM_PICKUP_BOMBBAG, 0, 0, LAYER.PLAYER1)
end
end, ON.LEVEL)
function register_option_bool(name: string, desc: string, long_desc: string, value: boolean)
name: string
desc: string
long_desc: string
value: boolean

Add a boolean option that the user can change in the UI. Read with options.name, value is the default.

register_option_button

documented onlysource

function register_option_button(name: string, desc: string, long_desc: string, on_click: function)
name: string
desc: string
long_desc: string
on_click: function

Add a button that the user can click in the UI. Sets the timestamp of last click on value and runs the callback function.

register_option_callback

source

function register_option_callback(name: string, value: any, on_render: fun(draw_ctx: GuiDrawContext): any)
name: string
value: any
on_render: fun(draw_ctx: GuiDrawContext): any
Returning nil (or nothing): no override: the C++ side keeps its default.

Add custom options using the window drawing functions. Everything drawn in the callback will be rendered in the options window and the return value saved to options[name] or overwriting the whole options table if using and empty name. value is the default value, and pretty important because anything defined in the callback function will only be defined after the options are rendered. See the example for details.
The callback signature is optional on_render(GuiDrawContext draw_ctx)

register_option_combo

documented onlysource

function register_option_combo(name: string, desc: string, long_desc: string, opts: string, value: integer)
name: string
desc: string
long_desc: string
opts: string
value: integer

Add a combobox option that the user can change in the UI. Read the int index of the selection with options.name. Separate opts with \0, with a double \0\0 at the end. value is the default index 1..n.

register_option_float

documented onlysource

function register_option_float(name: string, desc: string, long_desc: string, value: number, min: number, max: number)
name: string
desc: string
long_desc: string
value: number
min: number
max: number

Add a float option that the user can change in the UI. Read with options.name, value is the default. Keep in mind these are just soft limits, you can override them in the UI with double click.

register_option_int

documented onlysource

function register_option_int(name: string, desc: string, long_desc: string, value: integer, min: integer, max: integer)
name: string
desc: string
long_desc: string
value: integer
min: integer
max: integer

Add an integer option that the user can change in the UI. Read with options.name, value is the default. Keep in mind these are just soft limits, you can override them in the UI with double click.

register_option_string

documented onlysource

function register_option_string(name: string, desc: string, long_desc: string, value: string)
name: string
desc: string
long_desc: string
value: string

Add a string option that the user can change in the UI. Read with options.name, value is the default.

unregister_option

source

function unregister_option(name: string)
name: string

Removes an option by name. To make complicated conditionally visible options you should probably just use register_option_callback though.