AddEventHandler: Difference between revisions
Jump to navigation
Jump to search
Complete Lua function catalog |
Document expanded scripting capacities and complete audited limits for 0.1.3 BUILD81 |
||
| Line 1: | Line 1: | ||
= addEventHandler = | = addEventHandler = | ||
Attaches a Lua callback to a named event in the current resource. | Attaches a Lua callback to a named event in the current resource. | ||
| Line 36: | Line 35: | ||
== Notes == | == Notes == | ||
* Available in both client-side and server-side resource scripts. | * Available in both client-side and server-side resource scripts. | ||
* Expanded limits apply from update 0.1.3 BUILD81. Client limits: 8192 total handlers per resource and 512 handlers per event. The server has no matching fixed handler-count cap. See [[Scripting limits]]; earlier 0.1.3 binaries retain their old limits. | |||
[[Category:Lua Functions]] | [[Category:Lua Functions]] | ||
[[Category:Shared Functions]] | [[Category:Shared Functions]] | ||
[[Category:Event Functions]] | [[Category:Event Functions]] | ||
Latest revision as of 11:51, 12 September 2026
addEventHandler
Attaches a Lua callback to a named event in the current resource.
Syntax
bool addEventHandler(string eventName, element attachedTo, function handler)
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
eventName |
string |
yes | The event to listen for. |
attachedTo |
element |
yes | The attachment target. Use root for a global resource handler.
|
handler |
function |
yes | The callback invoked when the event is triggered. |
Returns
Returns true when the handler is registered; otherwise returns false.
Examples
Handle a custom event:
addEvent("quest:updated")
local function onQuestUpdated(questId)
print("Quest updated:", questId)
end
addEventHandler("quest:updated", root, onQuestUpdated)
Notes
- Available in both client-side and server-side resource scripts.
- Expanded limits apply from update 0.1.3 BUILD81. Client limits: 8192 total handlers per resource and 512 handlers per event. The server has no matching fixed handler-count cap. See Scripting limits; earlier 0.1.3 binaries retain their old limits.