What it does
Sends a message to every scene entity that matches an id, a name or a tag. Their scripts receive it through onMessage.
Syntax
1
EntitySend(entity string, message string) → integer2
EntitySend(entity string, message string, dataJson string) → integerParameters
| Name | Type | In forms | Meaning |
|---|---|---|---|
| entity | string | all | The id, name or tag of the receivers. Every matching entity gets the message. |
| message | string | all | The message name. |
| dataJson | string | 2 | Optional data sent with the message, as JSON text. Text that is not valid JSON is sent as a plain string. |
Every form returns
integer
The number of entities that received the message, 0 when none matches.
Good to know
- When nothing matches, one warning is written to the console, once per name.
Example · generated
Form 1, the short one
DO Print(EntitySend("value", "hello")) Sync()LOOPForm 2, with every argument
DO Print(EntitySend("value", "hello", "{}")) Sync()LOOPEntitySend is called and its answer is printed every frame. The DO … LOOP is not decoration: a classic BASIC program ends the moment it runs out of lines, and Sync() is what draws the frame.