Skip to content

Events

Register a function to run on an event with client.set_event_callback. The callback gets one table argument. Unknown event names raise an error at registration.

client.set_event_callback("paint", function(e)
-- e is the event's table argument
end)

Remove it again with client.unset_event_callback(name, fn). Register callbacks from the top level so each closure captures the script’s own upvalues.

Every game adds its own events on top of these; see the game’s page under Games.

Fired once per frame, on the game thread. The only event renderer.* may draw in. Runs on a small time and instruction budget.

Examples:

client.set_event_callback("paint", function()
renderer.text(15, 15, 255, 255, 255, 255, nil, 0, "hello world")
end)

Fired when the script is unloading, before its Lua state is closed. Use it to persist state or clear anything you set up. An error here is logged and the script unloads anyway.

Examples:

client.set_event_callback("shutdown", function()
database.write("last_seen", client.unix_time())
end)

Fired when the Lynx menu opens.

Fired when the Lynx menu closes.

Examples:

client.set_event_callback("menu_close", function()
client.log("menu closed")
end)