Sharp Aion2 Lua SDK
API reference

ui_sdkLua module

Build windows with the bundled Lua UI helper.

Import this library with local ui_sdk = require("ui_sdk"). ui_sdk.version is its installed version. ui_sdk.window opens and closes a ui window; the other helpers call the corresponding ui function inside it. Keep widget values between ticks.

Themes and media (ui_sdk 1.7.0)

These additions require an installed ui_sdk 1.7.0, included in SDK 1.7.20. SDK 1.7.18 and 1.7.19 contain ui_sdk 1.6.0; update the SDK and reload the module. Check ui_sdk.version and the loaded client's media functions before using them. Media widgets also require a loaded client that provides ui.image and ui.video. Updating the Lua helper alone does not add these client functions.

ui_sdk.register_theme(name, style)

Register a reusable window style in this module. Names use 1–64 letters, digits, _ or -. Properties are the same as a window's style table. The table is copied, so later edits do not change the registered theme. Built-in names are dark, transparent and light.

ui_sdk.theme(name, overrides)

Return a new style table combining a registered theme with optional overrides. An unknown name raises an error. Pass theme = name in window geometry to select it directly; style overrides individual properties. Selections belong to the module; save them through your script's settings if they should survive reloads.

ui_sdk.image(id, path, options)

ui_sdk.video(id, path, options)

Add the corresponding media widget inside a window. These helpers exist only when the loaded client supports them. Videos are muted.

local ui_sdk = require("ui_sdk")
ui_sdk.register_theme("my_panel", {
    background = ui_sdk.rgba(15, 25, 35, 240),
    button = ui_sdk.rgba(35, 100, 155),
    window_rounding = 12,
})

function on_tick()
    local ok, err = ui_sdk.window("media", "My panel", {
        x = 80, y = 100, width = 520, height = 600,
        theme = "my_panel", style = {opacity = 0.85},
    }, function(panel)
        if not panel.image or not panel.video then
            panel.text("Update the client to use media widgets.")
            return
        end
        panel.image("logo", "logo.png", {height = 120})
        panel.video("intro", "intro.mp4", {height = 220, loop = true})
    end)
    if not ok then log.warn(err) end
end

Put these files in media inside the Scripts folder shown in the Scripts tab. Theme registration and media options do not change the main menu or other modules.

ui_sdk.window(id, title, geometry, build)

Parameters: id and title identify the window; geometry contains x, y, width, height, optional style and, with ui_sdk 1.7.0, optional theme; build is a function receiving ui_sdk. Returns: true after the window is drawn, or nil, error if opening or closing fails. An error inside build raises a Lua error after the window closes.

local ui_sdk = require("ui_sdk")
local count = 0
function on_tick()
    local ok, err = ui_sdk.window("counter", "Counter", {
        x = 80, y = 120, width = 250, height = 150,
    }, function(ui)
        ui.text("Clicks: " .. count)
        if ui.button("add", "Add") then count = count + 1 end
    end)
    if not ok then log.warn(err) end
end

ui_sdk.rgba(red, green, blue, alpha)

Parameters: Each channel is an integer from 0 to 255; alpha defaults to 255. Returns: Packed 0xAABBGGRR color. Invalid channels raise a Lua error.

local accent = ui_sdk.rgba(35, 95, 140)

Controls

Each helper below has the same parameters and successful result as its ui counterpart. A failed call raises a Lua error, which ui_sdk.window closes safely before re-raising.

ui_sdk.text(message)

Parameters: Text. Result: Adds a label.

ui_sdk.text_colored(message, color)

Parameters: Text and packed color. Result: Adds a colored label.

ui_sdk.separator()

Parameters: None. Result: Adds a divider.

ui_sdk.same_line()

Parameters: None. Result: Uses the current row.

ui_sdk.button(id, label)

Parameters: Widget ID and label. Result: true once when clicked, otherwise false.

ui_sdk.checkbox(id, label, value)

Parameters: Widget ID, label, and previous boolean. Result: Current boolean.

ui_sdk.slider_float(id, label, value, minimum, maximum)

Parameters: Widget ID, label, previous number, and bounds. Result: Current number.

ui_sdk.input_text(id, label, value)

Parameters: Widget ID, label, and previous text. Result: Edited text.

local ui_sdk = require("ui_sdk")
local enabled = false
function on_tick()
    local ok, err = ui_sdk.window("options", "Options", {
        x = 80, y = 120, width = 250, height = 140,
    }, function(ui)
        enabled = ui.checkbox("enabled", "Enabled", enabled)
    end)
    if not ok then log.warn(err) end
end

Charts (ui_sdk 1.5.0)

These helpers exist only when the loaded DLL exposes ui.chart. They have the native chart's sample/size/range limits and raise native errors through the helper. Check ui_sdk.plot_lines before using charts on older clients.

ui_sdk.chart(id, label, samples, options)

Same parameters and queue acknowledgement as ui.chart.

ui_sdk.plot_lines(id, label, samples, options)

Selects a line chart. Copies the options table before selecting the type; the caller's options are unchanged.

ui_sdk.plot_bars(id, label, samples, options)

Selects a bar chart. Automatic ranges include zero so negative values draw below the baseline.

local Ui = require("ui_sdk")
function on_tick()
    local opened, err = Ui.window("charts", "Sample charts", {
        x = 80, y = 80, width = 600, height = 460,
    }, function(ui_sdk)
        if not ui_sdk.plot_lines then
            ui_sdk.text("Charts require an updated loaded DLL and ui_sdk 1.5.0.")
            return
        end
        ui_sdk.plot_lines("prices", "Sample prices", {100, 95, 120}, {
            height = 160, color = ui_sdk.rgba(83, 207, 220),
        })
        ui_sdk.plot_bars("net", "Sample net results", {-20, 50, 30}, {
            height = 160, color = ui_sdk.rgba(247, 174, 85),
        })
    end)
    if not opened then log.warn(err) end
end

On this page