Assignment Client (AC) scripts (also known as "persistent scripts") run persistently in a domain and aren't affected by other scripts. These scripts run on an assignment client separate from the Interface, so the script will continue to run until you either remove the script from the domain or you shut down the domain entirely.
With AC scripts, you can do things like coordinate actions between entities and avatars, and add virtual pets to greet visitors to your domain.
On This Page
Once you've written and hosted your script, you need to add it to a domain, either your own or one where you have permissions to run an AC script.
The following script counts the number of entities found in a domain using High Fidelity's EntityViewer.
var SEARCH_CENTER = {x: 0, y: -10, z: 0};
var SEARCH_RADIUS = 100;
var isInitialized = false;
var timeout = 1000;
var update = function(deltaTime) {
if (!isInitialized) {
if (Entities.serversExist() && Entities.canRez()) {
EntityViewer.setPosition(SEARCH_CENTER);
EntityViewer.setCenterRadius(SEARCH_RADIUS);
EntityViewer.queryOctree();
Script.setTimeout(function(){
var foundEntities = Entities.findEntities(SEARCH_CENTER, SEARCH_RADIUS).length;
print("AC Script found: " + foundEntities + " entities within " + SEARCH_RADIUS + "m of " + JSON.stringify(SEARCH_CENTER));
}, timeout);
isInitialized = true;
Script.update.disconnect(update);
}
}
};
Script.update.connect(update);
See Also