### Dialog Example
Source: https://foundryvtt.com/api/v14/classes/foundry.appv1.api.Dialog.html
Example of how to construct and render a custom dialog instance with multiple button options.
```javascript
let d = new Dialog({
title: "Test Dialog",
content: "
You must choose either Option 1, or Option 2
",
buttons: {
one: {
icon: '',
label: "Option One",
callback: () => console.log("Chose One")
},
two: {
icon: '',
label: "Option Two",
callback: () => console.log("Chose Two")
}
},
default: "two",
render: html => console.log("Register interactivity in the rendered dialog"),
close: html => console.log("This always is logged no matter which option is chosen")
});
d.render(true);
```
--------------------------------
### setupGame
Source: https://foundryvtt.com/api/v14/classes/foundry.Game.html
Fully sets up the game state, including documents, UI, and canvas, and triggers setup and ready hooks.
```APIDOC
## setupGame
### Description
Fully set up the game state, initializing Documents, UI applications, and the Canvas. Triggers the hookEvents.setup and hookEvents.ready events.
### Method
setupGame(): Promise
### Returns
Promise
```
--------------------------------
### Filter Journal Entries
Source: https://foundryvtt.com/api/v14/classes/foundry.documents.collections.Journal.html
Filter the Collection to return an Array of entries that match a functional condition. This example filters for entries starting with 'A'.
```javascript
let c = new Collection([["a", "AA"], ["b", "AB"], ["c", "CC"]]);
let hasA = c.filters(entry => entry.slice(0) === "A");
```
--------------------------------
### ready()
Source: https://foundryvtt.com/api/v14/functions/hookEvents.ready.html
Fires once when the game is fully ready. This hook runs after the 'setup' hook.
```APIDOC
## ready()
### Description
A hook event that fires once when the game is fully ready. Runs after `setup`.
### Method
`ready()`
### Returns
void
```
--------------------------------
### Retrieve an existing Actor by its id
Source: https://foundryvtt.com/api/v14/classes/foundry.documents.collections.Actors.html
This example demonstrates how to get a specific Actor document from the game.actors collection using its unique ID.
```APIDOC
## Retrieve an existing Actor by its id
### Description
This example demonstrates how to get a specific Actor document from the game.actors collection using its unique ID.
### Method
GET
### Endpoint
`game.actors.get(actorId)`
### Parameters
#### Path Parameters
- **actorId** (string) - Required - The unique identifier of the Actor to retrieve.
### Response
#### Success Response (200)
- **Actor** (foundry.documents.Actor) - The retrieved Actor document.
#### Response Example
```json
{
"example": "actorDocument"
}
```
```
--------------------------------
### SetupTour Methods
Source: https://foundryvtt.com/api/v14/classes/foundry.nue.tours.SetupTour.html
Provides methods for controlling and interacting with the SetupTour.
```APIDOC
## Methods
### complete
* complete(): Promise
Advance the tour to a completed state.
### Returns
Promise
### exit
* exit(): void
Exit the tour at the current step.
### Returns
void
### next
* next(): Promise
Progress the Tour to the next step.
### Returns
Promise
### previous
* previous(): Promise
Rewind the Tour to the previous step.
### Returns
Promise
### progress
* progress(stepIndex: number): Promise
Progresses to a given Step
### Parameters
* stepIndex: number
The step to progress to
### Returns
Promise
### reset
* reset(): Promise
Reset the Tour to an un-started state.
### Returns
Promise
### start
* start(): Promise
Start the Tour at its current step, or at the beginning if the tour has not yet been started.
### Returns
Promise
```
--------------------------------
### Create and Evaluate a PoolTerm
Source: https://foundryvtt.com/api/v14/classes/foundry.dice.terms.PoolTerm.html
Instantiate a PoolTerm with multiple dice expressions and modifiers, then evaluate it to get the results. This example demonstrates keeping the highest die from each of the three specified rolls.
```javascript
let pool = new PoolTerm({
terms: ["4d6", "3d8 - 1", "2d10 + 3"],
modifiers: ["kh"]
});
pool.evaluate();
```
--------------------------------
### SetupTour Constructor
Source: https://foundryvtt.com/api/v14/classes/foundry.nue.tours.SetupTour.html
Constructs a new SetupTour instance. It requires a TourConfig object and accepts optional configuration options.
```APIDOC
## constructor
* new SetupTour(
config: TourConfig,
options?: { id?: string; namespace?: string },
): SetupTour
Construct a Tour by providing a configuration.
### Parameters
* config: TourConfig
The configuration of the Tour
* `Optional`options: { id?: string; namespace?: string } = {}
Additional options for configuring the tour
* ##### `Optional`id?: string
A tour ID that supercedes TourConfig#id
* ##### `Optional`namespace?: string
A tour namespace that supercedes TourConfig#namespace
### Returns
SetupTour
```
--------------------------------
### Define Schema and Localization Prefixes for DataModel
Source: https://foundryvtt.com/api/v14/classes/foundry.abstract.TypeDataModel.html
Example of defining a schema for a custom DataModel and setting localization prefixes. This setup allows Foundry to automatically localize field labels and hints based on a provided JSON structure.
```javascript
class MyDataModel extends foundry.abstract.DataModel {
static defineSchema() {
return {
foo: new foundry.data.fields.StringField(),
bar: new foundry.data.fields.NumberField()
};
}
static LOCALIZATION_PREFIXES = ["MYMODULE.MYDATAMODEL"];
}
Hooks.on("i18nInit", () => {
// Foundry will attempt to automatically localize models registered for a document subtype, so this step is only
// needed for other data model usage, e.g. for a Setting.
Localization.localizeDataModel(MyDataModel);
});
```
--------------------------------
### get
Source: https://foundryvtt.com/api/v14/classes/foundry.abstract.SingletonEmbeddedCollection.html
Get a document from the EmbeddedCollection by its ID.
```APIDOC
## get
### Description
Get a document from the EmbeddedCollection by its ID.
### Parameters
#### id
- string - The ID of the Embedded Document to retrieve.
#### options
- { invalid?: boolean; strict?: boolean } - Optional. Additional options to configure retrieval.
- invalid?: boolean - Allow retrieving an invalid Embedded Document.
- strict?: boolean - Throw an Error if the requested Embedded Document does not exist.
### Returns
any - The retrieved document instance, or undefined
### Throws
If strict is true and the Embedded Document cannot be found.
```
--------------------------------
### initialize
Source: https://foundryvtt.com/api/v14/classes/foundry.canvas.sources.BaseLightSource.html
Initialize the light source with data.
```APIDOC
## initialize
### Description
Initialize the light source with data.
### Method
`_initialize(data: any): void`
### Parameters
#### Path Parameters
- **data** (any) - Description not available
```
--------------------------------
### initialize
Source: https://foundryvtt.com/api/v14/classes/foundry.documents.collections.Playlists.html
Perform one-time initialization to begin playback of audio.
```APIDOC
## initialize
### Description
Perform one-time initialization to begin playback of audio.
### Method
`initialize(): Promise`
### Returns
- **Promise**
```
--------------------------------
### get
Source: https://foundryvtt.com/api/v14/classes/foundry.abstract.EmbeddedCollection.html
Get a document from the EmbeddedCollection by its ID.
```APIDOC
## get
### Description
Get a document from the EmbeddedCollection by its ID.
### Method
get
### Parameters
#### Path Parameters
- **id** (string) - Required - The ID of the Embedded Document to retrieve.
#### Query Parameters
- **options** (object) - Optional - Additional options to configure retrieval.
- **invalid** (boolean) - Optional - Allow retrieving an invalid Embedded Document.
- **strict** (boolean) - Optional - Throw an Error if the requested Embedded Document does not exist.
### Returns
TDocument - The retrieved document instance, or undefined
### Throws
If strict is true and the Embedded Document cannot be found.
```
--------------------------------
### _onConfigure
Source: https://foundryvtt.com/api/v14/classes/foundry.applications.apps.av.CameraViews.html
Handles spawning the AV configuration dialog.
```APIDOC
## _onConfigure
### Description
Handle spawning the AV configuration dialog.
### Method
Internal
### Signature
_onConfigure(event: PointerEvent, target: HTMLElement): Promise
### Parameters
#### Path Parameters
- **event** (PointerEvent) - The triggering event.
- **target** (HTMLElement) - The action target.
### Returns
Promise
```
--------------------------------
### get
Source: https://foundryvtt.com/api/v14/classes/foundry.documents.collections.Playlists.html
Get a Playlist document from the collection by its ID.
```APIDOC
## get
### Description
Get a Playlist document from the collection by its ID.
### Method
get
### Parameters
#### Path Parameters
* id (string) - Required - The ID of the Document to retrieve.
* options (object) - Optional - Additional options to configure retrieval.
* invalid (boolean) - Optional - Allow retrieving an invalid Document.
* strict (boolean) - Optional - Throw an Error if the requested Document does not exist.
### Returns
documents.Playlist
### Throws
If strict is true and the Document cannot be found.
```
--------------------------------
### initialize
Source: https://foundryvtt.com/api/v14/classes/foundry.nue.NewUserExperienceManager.html
Initializes the new user experience, generating introductory chat messages for new worlds.
```APIDOC
## initialize
### Description
Initialize the new user experience. Currently, this generates some chat messages with hints for getting started if we detect this is a new world.
### Method
initialize(): void
### Parameters
#### Path Parameters
* None
#### Query Parameters
* None
#### Request Body
* None
### Returns
* **void**
```
--------------------------------
### Starting and Stopping Particle Effects
Source: https://foundryvtt.com/api/v14/classes/foundry.canvas.animation.ParticleGenerator.html
Demonstrates how to start and stop a particle generator after it has been configured.
```APIDOC
## ParticleGenerator Methods
### start()
#### Description
Starts the particle generator, beginning the emission of particles according to its configuration.
### stop()
#### Description
Stops the particle generator, ceasing the emission of new particles. Existing particles will continue their animation until they expire or are otherwise removed.
```
--------------------------------
### get
Source: https://foundryvtt.com/api/v14/classes/foundry.documents.Combatant.html
Retrieves a World-level Combatant Document by its ID. Supports optional database get operations.
```APIDOC
## Static get
### Description
Get a World-level Document of this type by its id.
### Method
`Static` get
### Parameters
* **documentId** (string) - Required - The Document ID
* **operation** (DatabaseGetOperation) - Optional - Parameters of the get operation
### Returns
Document