Skip to main content

LuaEvents.Add(string eventName, function handler)

Adds the handler function to the event with name provided on eventName. The eventName doesn't need to be unique, or defined before. Throws error if handler is not a callable type. Each handler will receive a unique key (LuaEventId) which can used to remove the handler.

Parameters:

NameTypeDescription
eventNamestringThe name of the event this handler get's attached to.
handlerfunctionThe handler function.

Returns:

typeDescription
LuaEventIdA unique key identifying the handler.

Usage

---@type string
local eventName;

---@type function
local handler;


local val0 = LuaEvents:Add(eventName, handler)