Home / Events

emit()

emit(name, dataTable)

Dispatches a custom event to listeners.

Parameters

NameTypeDescription
namestringThe name of the custom event.
dataTabletableTable containing event data to pass to listeners.

Returns

Two values: the final cancelled boolean and the event table.

Example

local cancelled, e = emit("myCustomEvent", { foo = "bar" })
if not cancelled then
  log("Event ran successfully.")
end

Notes

The supplied table is copied into a new event table; its cancel field is ignored, and source is set to the emitting plugin's name. Cancellation is a shared flag, not an instruction to stop dispatching later listeners.