Description
Supported Script Types: Interface Scripts • Client Entity Scripts • Avatar Scripts • Server Entity Scripts • Assignment Client Scripts
The Messages API enables text and data to be sent between scripts over named "channels". A channel can have
an arbitrary name to help separate messaging between different sets of scripts.
Note: To call a function in another script, you should use one of the following rather than sending a message:
Methods
| Name | Return Value | Summary |
|---|---|---|
sendData
|
None |
Sends a data message on a channel. |
sendLocalMessage
|
None |
Sends a text message locally on a channel.
This is the same as calling sendMessage with |
sendMessage
|
None |
Sends a text message on a channel. |
subscribe
|
None |
Subscribes the scripting environment — Interface, the entity script server, or assignment client instance — to receive messages on a specific channel. This means, for example, that if there are two Interface scripts that subscribe to different channels, both scripts will receive messages on both channels. |
unsubscribe
|
None |
Unsubscribes the scripting environment from receiving messages on a specific channel. |
Signals
| Name | Summary |
|---|---|
dataReceived
|
Triggered when a data message is received. |
messageReceived
|
Triggered when a text message is received. |
Method Details
| (static) sendData( channel, data, localOnlyopt ) | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Sends a data message on a channel. Parameters
ExampleSend and receive data.
|
| (static) sendLocalMessage( channel, message ) | |||||||||
|---|---|---|---|---|---|---|---|---|---|
|
Sends a text message locally on a channel.
This is the same as calling sendMessage with Parameters
|
| (static) sendMessage( channel, message, localOnlyopt ) | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Sends a text message on a channel. Parameters
ExampleSend and receive a message.
|
| (static) subscribe( channel ) | ||||||
|---|---|---|---|---|---|---|
|
Subscribes the scripting environment — Interface, the entity script server, or assignment client instance — to receive messages on a specific channel. This means, for example, that if there are two Interface scripts that subscribe to different channels, both scripts will receive messages on both channels. Parameters
|
| (static) unsubscribe( channel ) | ||||||
|---|---|---|---|---|---|---|
|
Unsubscribes the scripting environment from receiving messages on a specific channel. Parameters
|
Signal Details
|
dataReceived(
channel,
data,
senderID,
localOnly
)
Returns: Signal |
|||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Triggered when a data message is received. Parameters
|
|
messageReceived(
channel,
message,
senderID,
localOnly
)
Returns: Signal |
|||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Triggered when a text message is received. Parameters
|