Actors

One of the most fundamental entities within Foundry Virtual Tabletop is the Actor. Actors are the protagonists, enemies, allies, and personalities within the World that you create. The game System defines the exact types of actors which are relevant, but for most role-playing games actors will, at the very least, represent the characters which the players impersonate.

For application developers there are three important layers which are useful when working with Actors. The Actors() collection manages the set of actor entities which are present within the world. Each individual actor within that collection is an instance of the Actor() class (by default). Game systems which want more control over the behaviors and attributes of an actor may override this to a subclass included in their own definition.

When viewing or interacting with an actor inside the tabletop framework, the actor’s data is rendered and edited using the ActorSheet() class (by default). Game systems which want to fine-tune how the actor data is rendered may override this to a subclass included in their own definition.



The Actors Collection

class Actors()

The Collection() of Actor() entities The actors collection is accessible within the game as game.actors

Actors.Collection.insert(entity)

Add a new Entity to the Collection, asserting that they are of the correct type

Arguments:
  • entity (Entity) – The entity instance to add to the collection
Actors.Collection.remove(id)

Remove an Entity from the Collection by its ID.

Arguments:
  • id (String) – The entity ID which should be removed
Actors.Collection.get(id)

Get an element from the collection by ID

Arguments:
  • id (String) – The entity ID to retrieve from the collection
Returns:

Entity – The retrieved Entity, if the ID was found, otherwise null;

Actors.Collection.index(id)

Retrieve the index of an entity within the collection by its ID

Arguments:
  • id (String) – The entity ID to retrieve from the collection
Returns:

Number – The index of the Entity within the collection, if found, otherwise -1;

Actors.Collection.render()

Re-render any currently visible applications associated with this Collection

Actors.importFromCollection(collection, entryId)

Import an Actor from a compendium collection, adding it to the current World

Arguments:
  • collection (String) – The name of the pack from which to import
  • entryId (String) – The ID of the compendium entry to import
Returns:

Promise – A Promise containing the imported Actor

Actors.object

Elements of the Actors collection are instances of the Actor class, or a subclass thereof

Actors.socketListeners(socket)

Open additional socket listeners which transact Actor data


The Actor Class

class CONFIG.Actor()

Configuration for the default Actor entity class


The Actor Sheet

class ActorSheet(actor, options)

The default Actor Sheet

This is a Application() that is responsible for rendering an actor’s attributes and allowing the actor to be edited.

System modifications may elect to override this class to better suit their own game system by re-defining the value CONFIG.Actor.sheetClass.

For basic or aesthetic modifications, overriding this class entirely may not be necessary and you may simply wish to replace the default HTML template. This can be accomplished by re-defining CONFIG.ActorSheet.template.

Arguments:
  • actor (Actor) – The Actor instance being displayed within the sheet.
  • options (Object) – Additional options which modify the rendering of the Actor’s sheet.
  • options.editable (Boolean) – Is the Actor editable? Default is true.
ActorSheet.activateListeners(html)

Activate the default set of listeners for the Actor Sheet These listeners handle basic stuff like form submission or updating images

Arguments:
  • html (JQuery) – The rendered template ready to have listeners attached
ActorSheet.defaultOptions

Assign the default options which are supported by the CharacterSelect menu

ActorSheet.getData()

Prepare data for rendering the Actor sheet The prepared data object contains both the actor data as well as additional sheet options