Skip to content

Menu

The core.menu module lets scripts create custom settings that appear in the web UI under the Lua tab. Settings are persisted across sessions and can be read/written with core.get_setting() / core.set_setting().

All creation functions are idempotent — calling them again with an existing ID returns true without creating a duplicate.

Sandboxing

  • IDs are automatically prefixed with lua. — if you pass "myScript.enabled", it becomes "lua.myScript.enabled". If you already include the prefix, it's kept as-is. This prevents scripts from colliding with core settings.
  • All elements are placed in the "Lua" tab — the tab parameter is accepted but ignored. Use the panel parameter to organize your settings into sections within the Lua tab.

Functions

core.menu.create_checkbox(id, label, tab, panel, default_value [, tooltip]) -> boolean

Creates a checkbox setting.

lua
core.menu.create_checkbox("myScript.enabled", "Enable Feature", "Lua", "My Script", false, "Toggles the feature")
-- Registered as: id="lua.myScript.enabled", tab="Lua", panel="My Script"

core.menu.create_slider_int(id, label, tab, panel, default, min, max [, step [, tooltip]]) -> boolean

Creates an integer slider setting. step defaults to 1.

lua
core.menu.create_slider_int("myScript.delay", "Delay (ms)", "Lua", "My Script", 100, 0, 5000, 50)

core.menu.create_slider_float(id, label, tab, panel, default, min, max [, step [, tooltip [, rounding]]]) -> boolean

Creates a float slider setting. step defaults to 0.1, rounding controls decimal places (default: 2).

lua
core.menu.create_slider_float("myScript.speed", "Speed", "Lua", "My Script", 1.0, 0.1, 5.0, 0.1, "", 1)

core.menu.create_dropdown(id, label, tab, panel, options, default_index [, tooltip]) -> boolean

Creates a dropdown setting. options is a Lua array of strings, default_index is 0-based.

lua
core.menu.create_dropdown("myScript.mode", "Mode", "Lua", "My Script", {"Easy", "Normal", "Hard"}, 0)

core.menu.create_keybind(id, label, tab, panel [, default_key [, tooltip]]) -> boolean

Creates a keybind setting.

lua
core.menu.create_keybind("myScript.toggle", "Toggle Key", "Lua", "My Script", "", "Key to toggle feature")

core.menu.create_input_text(id, label, tab, panel [, default_value [, tooltip]]) -> boolean

Creates a text input setting.

lua
core.menu.create_input_text("myScript.name", "Character Name", "Lua", "My Script", "", "Target character")

Example

lua
plugin = {
    name = "My Script",
    version = "1.0.0",
    author = "Author",
    description = "Example with custom settings",
    load = true
}

-- Create settings once at load time (idempotent)
-- IDs are auto-prefixed with "lua." — these become lua.myScript.enabled, etc.
core.menu.create_checkbox("myScript.enabled", "Enable", "Lua", "My Script", false)
core.menu.create_slider_int("myScript.delay", "Delay (ms)", "Lua", "My Script", 200, 50, 5000, 50)
core.menu.create_dropdown("myScript.mode", "Mode", "Lua", "My Script", {"Safe", "Fast"}, 0)

function on_tick()
    local player = core.object_manager.get_local_player()
    if not player or not player:is_valid() then return end

    -- Read custom settings (use the full prefixed ID)
    local enabled = core.get_setting("lua.myScript.enabled")
    if not enabled then return end

    local delay = core.get_setting("lua.myScript.delay")
    local mode = core.get_setting("lua.myScript.mode")

    core.log("Running in mode " .. tostring(mode) .. " with delay " .. tostring(delay))
end