The CustomEvent represents any event that has been fired from some Lua code using Events.fire(), for example:
Events.fire("my-event", {someKey="some data"})
The CustomEvent class is a subtype of the Event class and inherits all its properties and functions.
Here is an overview of the CustomEvent properties:
Property | Type | read / write |
---|---|---|
data | any | r |
Below you find short descriptions about each of the properties and some examples about how to use them in your spells.
The data value that has been sent with this event. See Events.fire() for more details on this.
Firing a custom event with some complex data.
local data = {pos=spell.pos, time=Time.gametime}
Events.fire("my-event", data)
Accessing the data of a custom event.
local q = Events.collect("my-event")
local event = q:next()
print("event.data", str(event.data))