Signals namespace is how you broadcast messages between entities in the level. A signal carries an identifier string and optional data payload; any entity that listens for that identifier will receive the signal and can act on it. You choose the delivery scope — all entities, a single target, a tag group, a type group, or entities that pass a custom filter function.
Functions
emit
Dispatches a pre-built Signal object, or constructs one inline from a property table.
emitToAll
Broadcasts a signal to every entity in the level, optionally with a data payload.
emitTo
Sends a signal to a single specific entity.
emitToTag
Sends a signal to every entity that carries the given tag string.
emitToType
Sends a signal to every entity of a given EntityType.
emitToTypeAndTag
Sends a signal to every entity that matches both the given type and tag.
emitToCustom
Sends a signal to every entity for which customFilter(entity, signal) returns true.
Signal Class
You can construct aSignal object manually when you need full control over all delivery options. Pass it to Signals.emit().
Properties
| Property | Type | Description |
|---|---|---|
signal.id | string | The signal identifier string (required). |
signal.data | any | Optional payload delivered alongside the signal. |
signal.target | Element | If set, only this entity receives the signal. |
signal.tagFilter | string | If set, only entities with this tag receive the signal. |
signal.typeFilter | EntityType | Only entities of this type receive the signal. Defaults to EntityType.Any. |
signal.customFilter | function | If set, called for each candidate entity; return true to include it. |
Signal.new
id are optional: