Actor
An Actor is a container for code that can be safely split into its own thread.
Memory category | PhysicsParts |
---|
Member index 3
Description
An Actor is a container for code that can be safely split into its own thread using task.desynchronize(). It should also contain the instances used by its scripts.
To learn more about using multiple Actors to optimize script performance, see Parallel Luau.
History 8
- 573 Change ReturnType of SendMessage from void to null
- 570 Change Parameters of SendMessage from (name: string, message: Tuple) to (topic: string, message: Tuple)
- 570 Change Parameters of BindToMessageParallel from (name: string, function: Function) to (topic: string, function: Function)
- 570 Change Parameters of BindToMessage from (name: string, function: Function) to (topic: string, function: Function)
- 568 Add SendMessage
- 568 Add BindToMessageParallel
- 568 Add BindToMessage
- 455 Add Actor
Members 3
BindToMessage
Parameters (2) | ||
---|---|---|
topic | string | |
function | Function | |
Returns (1) | ||
RBXScriptConnection |
This method is used to bind a Luau callback to a message with the specified topic. When a message is sent (using SendMessage()) to the topic specified the provided callback will be called in a serial execution context.
Multiple Luau callbacks may be bound to a single actor and even to a single message topic.
Note: Only the scripts which are descendants of an Actor may bind to its messages.
1 2 3 4 5 6 7 |
|
Thread safety | Safe |
---|
History 2
- 570 Change Parameters of BindToMessage from (name: string, function: Function) to (topic: string, function: Function)
- 568 Add BindToMessage
BindToMessageParallel
Parameters (2) | ||
---|---|---|
topic | string | |
function | Function | |
Returns (1) | ||
RBXScriptConnection |
This method is used to bind a Luau callback to a message with the specified topic. When a message is sent (using SendMessage()) to the topic specified the provided callback will be called in a parallel execution context.
Multiple Luau callbacks may be bound to a single actor and even to a single message topic.
Note: Only the scripts which are descendants of an Actor may bind to its messages.
1 2 3 4 5 6 7 |
|
Thread safety | Safe |
---|
History 2
- 570 Change Parameters of BindToMessageParallel from (name: string, function: Function) to (topic: string, function: Function)
- 568 Add BindToMessageParallel
SendMessage
Parameters (2) | ||
---|---|---|
topic | string | |
Returns (1) | ||
null |
Sends a message to an Actor. Messages are sent asynchronously, so the sender will not block or yield when calling the SendMessage() method.
Since a single Actor may receive different kinds of messages, a topic
parameter is used to distinguish between various kinds of messages.
See BindToMessage() for details on receiving a message sent using SendMessage().
1 2 |
|
Thread safety | Safe |
---|
History 3
- 573 Change ReturnType of SendMessage from void to null
- 570 Change Parameters of SendMessage from (name: string, message: Tuple) to (topic: string, message: Tuple)
- 568 Add SendMessage