Actors
The Actor library provides support for seamlessly running code within other global states.
getactors
Returns a list of actors that you are able to execute code inside of.
Example
Iterate through the list of actors and output them to the console.
run_on_actor
runs the code specified inside of that actor's global state.Example
Execute a simple Hello World! print script inside of the first actor present. (not all games contain Actors)
Example 2
Transfer a message between the actor global state and your state
local comm_id, event = create_comm_channel()
event.Event:Connect(function(data)
print(data) -- -> Hello World!
end)
run_on_actor(getactors()[1], [=[
local channel = get_comm_channel(...)
channel:Fire('print("Hello World!"')
]=], comm_id)