Skip to content

Callbacks

qqtnn edited this page Jun 1, 2024 · 1 revision

Callbacks Documentation

On Render Callback

on_render()

Note

All graphics-related elements (images, circles, rectangles, text) must be placed inside this callback.

On Update Callback

on_update()

Note

Ideal for most game logics and spell casts.

On Pre-Tick Callback

on_pre_tick()

Note

Designed for logics requiring anticipation of the next game tick.

On Render Menu Callback

on_render_menu()

Note

All menu elements must be rendered in this callback. [!WARNING] All menu elements id must be unique otherwise they will overlap with other menu elements at saving.

local developer_id = "rename_me";
local check_test = checkbox:new(true, get_hash("developer_id .. "check_test"))

local function my_render_menu()
    check_test:render("Test Checkbox", "");
end

-- register your local function into the callback
on_render_menu(my_render_menu;

On Keys Callbacks

on_key_press() on_key_release()

Note

Triggers when any key is either press or released.

Lua Code Examples:

Register callback into anonimous function

on_key_release(function(key)
    print("Key Released:", key);
end);

Register callback into a local function

local function my_on_key_press(key)
    if key == 0x01 then
        console.print("Key Pressed is LMB");
    end;
end

on_key_press(my_on_key_press);
Clone this wiki locally