← Dialogue Documentation Home


Director Overview

The director is responsible for directing actions to the workers. Actions are asynchronous tasks that are created by the actors.

Direction function

Director(action [, worker_id])

action is an action table.

If worker_id is passed then the action will be given to the worker whose id is worker_id.

This function is automatically called with the correct action and worker_id when using the tones or actor:async methods.

This function is used internally for dispatching the actions of Dialogue to the workers and generally will not be used directly.

↑ top


Actions are serialized actor method calls. Actions include all the arguments and the id of the actor responsible for the method call.

{ actor_id, "method" [, arg1 [, ... [, argN]]] }

actor_id is the id returned from actor:id. "method" is a string which is the name of the method. arg1 ... argN are the arguments to that method.

For example, if there were an actor with an id of 4 and we wanted to remove it, instead of calling actor:remove() we could call Director{4, "remove"}.

For another example, if we wanted to create a child asynchronously, we might call the director like so: Director{4, "child", { "child-script" }}. Note that the previous call is equivalent to Actor(4):async("child", {"child-script"}) or just actor:async("child", {"child-script"}) if actor is the actor object with an id of 4.

Note that all messages are also actions and are sent through the actor:async method.

↑ top


A worker is simply a thread. When referring to workers in the plural, we mean a pool of threads. The Director function above is a dispatch for the actions. All actions of Dialogue are given to a worker, making actions asynchronous. All actor methods can be called synchronously rather than through an action.

↑ top