The Active Worlds SDK can support multiple simultaneous instances. This means it is possible to write an SDK application that creates and manipulates dozens or even hundreds of bots at once. The only practical limit on the number of instances is the limit on the number of bots that a citizen can have running in the universe at one time.
Each call to aw_create returns a separate instance handle. Multi-instance applications should save this handle and pass it back to the SDK via aw_instance_set before calling any method, to indicate which instance the call is for.
The Current Instance
At any given moment, one instance is always the current instance. In multi-instance applications, the current instance is changing constantly, in response to calls to the API and also in response to events. At any given time the application can query the current instance by calling aw_instance, and change the current instance by calling aw_instance_set. All API methods operate on the current instance, which means a multi-instance application must typically call aw_instance_set before any other method in order to indicate which instance the call is for.
The code sample below demonstrates how an application might create three different bots at once and have each bot introduce itself. Error checking code has been removed for clarity.
void* bot1; void* bot2; void* bot3; aw_create (0, 0, &bot1); aw_create (0, 0, &bot2); aw_create (0, 0, &bot3); /* code here to log all bots into the universe and into the world and to set their positions */ ... aw_instance_set (bot1); aw_say ("Hello I'm bot #1"); aw_instance_set (bot2); aw_say ("Hello I'm bot #2"); aw_instance_set (bot3); aw_say ("Hello I'm bot #3");