Skip to content

Api > LuaEvents > Add()


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:⚓︎

Name Type Description
eventName string The name of the event this handler get's attached to.
handler function The handler function.

Returns:⚓︎

type Description
LuaEventId A unique key identifying the handler.

Usage⚓︎

---@type string
local eventName;

---@type function
local handler;


local val0 = LuaEvents:Add(eventName, handler)