dispatch()
world.events.dispatch(target, name, data)
Description
Used to emit events that the listeners can listen to.
Parameters
Property | Type | Description |
---|---|---|
target | eid | The entity that is you want the dispatch to target. |
name | string | The name of the event you want to dispatch. |
data (optional) | unknown | Custom data that is optionally emitted by the dispatch call. |
Returns
None.
Example
// This line emits an event to the eid of an enemy entity with the name attack with the
// damage the attack caused stored as the data parameter.
world.events.dispatch(eidOfEnemy, "attack", {damage: 10})