OnSignal hook matches that name can respond. Signals can carry any Lua value as a payload, so you can pass numbers, strings, tables, or even nothing at all.
Receiving a Signal: The OnSignal Hook
To make an entity respond to a signal, define OnSignal in its script. The game calls this function whenever a signal is delivered to that entity.
The Signal Object
The signal parameter gives you everything you need to act on the incoming message:
You can create a
Signal object manually if you need full control over filtering:
Emitting Signals: The Signals Namespace
The Signals namespace provides several functions that let you target signals precisely — from a broadcast to every entity in the level down to a single named entity.
Signals.emit(signal)
Emits a pre-built Signal object, respecting whatever filters are set on it.
Signals.emitToAll(signalId [, data])
Broadcasts a signal to every entity in the level.
Signals.emitTo(signalId, target [, data])
Sends a signal to one specific entity.
Signals.emitToTag(signalId, tag [, data])
Sends a signal to all entities that share a given tag.
Signals.emitToType(signalId, type [, data])
Sends a signal to all entities of a specific EntityType.
Signals.emitToTypeAndTag(signalId, type, tag [, data])
Sends a signal to all entities that match both a type and a tag — the most precise broadcast filter.
Signals.emitToCustom(signalId, customFilter [, data])
Sends a signal to every entity for which customFilter returns true. The filter receives the entity and the signal as arguments.
Signal Data
Thedata field accepts any Lua value — a plain boolean, a number, a string, or a full table with nested fields.
signal.data:
If you emit a signal without a
data argument, signal.data will be nil on the receiving end. Always guard with a nil check if the field is optional.