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.
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. The third argument of run_on_actor can anything, however you cannot pass types like tables and functions As they are from a different Lua VMExecute a simple Hello World! print script inside of the first actor present. (not all games contain Actors)
Transfer a message between the actor global state and your state You cannot transfer certain data types (tables, functions, etc, due it being from a different Lua VM)
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)
create_comm_channel
Returns a communication id, and a bindable event that can be used for transferring data between the actor global state and your stateisparallel
Returns a boolean dictating if the current thread is in parallel statePrints whether or not the current lua state is in parallel phase.
getactorthreads
Returns a list of threads that you are able to execute code inside of.
Iterate through the list of threads and output them to the console.
run_on_thread
Run on the first actor thread present (not all games contain actors)