Global

Members

(constant) AUDIO_FILE_EXTENSIONS :Array

Source:

The supported file extensions for audio-type files

Type:

(constant) BASE_ENTITY_TYPE :String

Source:

Define the string name used for the base entity type when specific sub-types are not defined by the system

Type:

(constant) CHAT_MESSAGE_TYPES :Object

Source:

Valid Chat Message types

Type:
  • Object

(constant) COMPENDIUM_ENTITY_TYPES :Array

Source:

The allowed Entity types which may exist within a Compendium pack This is a subset of ENTITY_TYPES

Type:

(constant) CONFIG :Object

Source:

Runtime configuration settings for Foundry VTT which exposes a large number of variables which determine how aspects of the software behaves.

Unlike the CONST analog which is frozen and immutable, the CONFIG object may be updated during the course of a session or modified by system and module developers to adjust how the application behaves.

Type:
  • Object

(constant) CORE_SUPPORTED_LANGUAGES :Array.<string>

Source:

Define the set of languages which have built-in support in the core software

Type:

(constant) DEFAULT_NOTE_ICON :String

Source:

The default artwork used for Note placeables if none is provided

Type:

(constant) DEFAULT_TOKEN :String

Source:

The default artwork used for Token images if none is provided

Type:

(constant) DICE_ROLL_MODES :Object

Source:

The supported dice roll visibility modes

Type:
  • Object

(constant) DRAWING_DEFAULT_VALUES :Object

Source:

The default configuration values used for Drawing objects

Type:
  • Object

(constant) DRAWING_FILL_TYPES :Object

Source:

The allowed fill types which a Drawing object may display NONE: The drawing is not filled SOLID: The drawing is filled with a solid color PATTERN: The drawing is filled with a tiled image pattern

Type:
  • Object

(constant) DRAWING_TYPES :Object

Source:

The allowed Drawing types which may be saved

Type:
  • Object
Source:

Define the allowed Entity types which may be dynamically linked in chat

Type:

(constant) ENTITY_PERMISSIONS :Object

Source:

Define the allowed permission levels for a non-user Entity. Each level is assigned a value in ascending order. Higher levels grant more permissions.

Type:
  • Object

(constant) ENTITY_TYPES :Array

Source:

Define the allowed Entity class types

Type:

(constant) EULA_VERSION :String

Source:

EULA version number

Type:

(constant) FOLDER_ENTITY_TYPES :Array

Source:

Define the allowed Entity types which Folders may contain

Type:

(constant) FOLDER_MAX_DEPTH :Number

Source:

The maximum allowed level of depth for Folder nesting

Type:

(constant) FONTS :Object

Source:

A configuration of font families which are initialized when the page loads

Type:
  • Object

(constant) GRID_MIN_SIZE :Number

Source:

The minimum allowed grid size which is supported by the software

Type:

(constant) GRID_TYPES :Object

Source:

The allowed Grid types which are supported by the software

Type:
  • Object

(constant) HTML_FILE_EXTENSIONS :Array.<string>

Source:

The allowed set of HTML template extensions

Type:

(constant) IMAGE_FILE_EXTENSIONS :Array

Source:

The supported file extensions for image-type files

Type:

(constant) MACRO_SCOPES :Array.<string>

Source:

An Array of valid MacroAction scope values

Type:

(constant) PACKAGE_AVAILABILITY_CODES :Object

Source:

Encode the reasons why a package may be available or unavailable for use

Type:
  • Object

(constant) PASSWORD_SAFE_STRING

Source:

A safe password string which can be displayed

(constant) PLAYLIST_MODES :Object

Source:

The allowed playback modes for an audio Playlist DISABLED: The playlist does not play on its own, only individual Sound tracks played as a soundboard SEQUENTIAL: The playlist plays sounds one at a time in sequence SHUFFLE: The playlist plays sounds one at a time in randomized order SIMULTANEOUS: The playlist plays all contained sounds at the same time

Type:
  • Object

(constant) SOFTWARE_UPDATE_CHANNELS :Object

Source:

The allowed software update channels

Type:
  • Object

(constant) SORT_INTEGER_DENSITY :Number

Source:

The default sorting density for manually ordering child objects within a parent

Type:

(constant) TABLE_RESULT_TYPES :Object

Source:

The allowed types of a TableResult document

Type:
  • Object

(constant) TEXT_ANCHOR_POINTS :Object

Source:

Define the valid anchor locations for a Tooltip displayed on a Placeable Object

Type:
  • Object

(constant) TOKEN_DISPLAY_MODES :Object

Source:

Describe the various thresholds of token control upon which to show certain pieces of information NONE - no information is displayed CONTROL - displayed when the token is controlled OWNER HOVER - displayed when hovered by a GM or a user who owns the actor HOVER - displayed when hovered by any user OWNER - always displayed for a GM or for a user who owns the actor ALWAYS - always displayed for everyone

Type:
  • Object

(constant) TOKEN_DISPOSITIONS

Source:

The allowed Token disposition types HOSTILE - Displayed as an enemy with a red border NEUTRAL - Displayed as neutral with a yellow border FRIENDLY - Displayed as an ally with a cyan border

(constant) USER_PERMISSIONS :Object

Source:

Define the named actions which users or user roles can be permitted to do. Each key of this Object denotes an action for which permission may be granted (true) or withheld (false)

Type:
  • Object

(constant) USER_ROLE_NAMES :Object

Source:

Invert the User Role mapping to recover role names from a role integer

Type:
  • Object

(constant) USER_ROLES :Object

Source:

Define the allowed User permission levels. Each level is assigned a value in ascending order. Higher levels grant more permissions.

Type:
  • Object

(constant) VIDEO_FILE_EXTENSIONS :Array

Source:

The supported file extensions for video-type files

Type:

(constant) WALL_DIRECTIONS :Object

Source:

The allowed directions of effect that a Wall can have BOTH: The wall collides from both directions LEFT: The wall collides only when a ray strikes its left side RIGHT: The wall collides only when a ray strikes its right side

Type:
  • Object

(constant) WALL_DOOR_STATES :Object

Source:

The allowed door states which may describe a Wall that contains a door CLOSED: The door is closed OPEN: The door is open LOCKED: The door is closed and locked

Type:
  • Object

(constant) WALL_DOOR_TYPES :Object

Source:

The allowed door types which a Wall may contain NONE: The wall does not contain a door DOOR: The wall contains a regular door SECRET: The wall contains a secret door

Type:
  • Object

(constant) WALL_MOVEMENT_TYPES :Object

Source:

The types of movement collision which a Wall may impose NONE: Movement does not collide with this wall NORMAL: Movement collides with this wall

Type:
  • Object

(constant) WALL_SENSE_TYPES :Object

Source:

The types of sensory collision which a Wall may impose NONE: Senses do not collide with this wall NORMAL: Senses collide with this wall LIMITED: Senses collide with the second intersection, bypassing the first

Type:
  • Object

Methods

_handleMouseWheelInputChange(event)

Source:

Support mousewheel control for range type input elements

Parameters:
Name Type Description
event WheelEvent

A Mouse Wheel scroll event

colorStringToHex(color) → {Number}

Source:

Convert a string color to a hex integer

Parameters:
Name Type Description
color String

The string color

Returns:

The hexidecimal color code

Type
Number

debounce(callback, delay) → {function}

Source:

Wrap a callback in a debounced timeout. Delay execution of the callback function until the function has not been called for delay milliseconds

Parameters:
Name Type Description
callback function

A function to execute once the debounced threshold has been passed

delay number

An amount of time in milliseconds to delay

Returns:
Type
function

diffObject(original, other) → {Object}

Source:

Deeply difference an object against some other, returning the update keys and values

Parameters:
Name Type Description
original Object
other Object
Returns:
Type
Object

duplicate(original)

Source:

A cheap data duplication trick, surprisingly relatively performant

Parameters:
Name Type Description
original Object

Some sort of data

encodeURL(path) → {string}

Source:

Encode a url-like string by replacing any characters which need encoding

Parameters:
Name Type Description
path string

A fully-qualified URL or url component (like a relative path)

Returns:

An encoded URL string

Type
string

expandObject(obj, _d) → {Object}

Source:

Expand a flattened object to be a standard multi-dimensional nested Object by converting all dot-notation keys to inner objects.

Parameters:
Name Type Default Description
obj Object

The object to expand

_d Number 0

Recursion depth, to prevent overflow

Returns:

An expanded object

Type
Object

filterObject(source, template, keepSpecial, templateValues)

Source:

Filter the contents of some source object using the structure of a template object. Only keys which exist in the template are preserved in the source object.

Example
const source = {foo: {number: 1, name: "Tim", topping: "olives"}, bar: "baz"};
const template = {foo: {number: 0, name: "Mit", style: "bold"}, other: 72};
filterObject(source, template); // {foo: {number: 1, name: "Tim"}};
filterObject(source, template, {templateValues: true}); // {foo: {number: 0, name: "Mit"}};
Parameters:
Name Type Description
source Object

An object which contains the data you wish to filter

template Object

An object which contains the structure you wish to preserve

keepSpecial boolean

Whether to keep special tokens like deletion keys

templateValues boolean

Instead of keeping values from the source, instead draw values from the template

flattenObject(obj, _d) → {Object}

Source:

Flatten a possibly multi-dimensional object to a one-dimensional one by converting all nested keys to dot notation

Parameters:
Name Type Default Description
obj Object

The object to flatten

_d Number 0

Recursion depth, to prevent overflow

Returns:

A flattened object

Type
Object

(async) fromUuid(uuid) → {Promise.<(Entity|Object|null)>}

Source:

Retrieve an Entity or Embedded Entity by its Universally Unique Identifier (uuid).

Parameters:
Name Type Description
uuid string

The uuid of the Entity or Embedded Entity to retrieve

Returns:
Type
Promise.<(Entity|Object|null)>

getProperty(object, key) → {*}

Source:

A helper function which searches through an object to retrieve a value by a string key. The string key supports the notation a.b.c which would return object[a][b][c]

Parameters:
Name Type Description
object Object

The object to traverse

key String

An object property with notation a.b.c

Returns:

The value of the found property

Type
*

(async) getTemplate(path) → {Promise}

Source:

Get a template from the server by fetch request and caching the retrieved result

Parameters:
Name Type Description
path string

The web-accessible HTML template URL

Returns:

A Promise which resolves to the compiled template or null

Type
Promise

getTexture(src) → {PIXI.Texture}

Source:

Get a single texture from the cache

Parameters:
Name Type Description
src string
Returns:
Type
PIXI.Texture

getType(token) → {string}

Source:

Learn the named type of a token - extending the functionality of typeof to recognize some core Object types

Parameters:
Name Type Description
token *

Some passed token

Returns:

The named type of the token

Type
string

hasProperty(object, key) → {Boolean}

Source:

A helper function which tests whether an object has a property or nested property given a string key. The string key supports the notation a.b.c which would return true if object[a][b][c] exists

Parameters:
Name Type Description
object Object

The object to traverse

key String

An object property with notation a.b.c

Returns:

An indicator for whether the property exists

Type
Boolean

hexToRGB(hex) → {Array}

Source:

Convert a hex color code to an RGB array

Parameters:
Name Type Description
hex number

A hex color number

Returns:

An array of [r,g,b] colors normalized on the range of [0,1]

Type
Array

hexToRGBAString(hex, alpha) → {string}

Source:

Convert a hex color code to an RGBA color string which can be used for CSS styling

Parameters:
Name Type Default Description
hex number

A hex color number

alpha number 1

A level of transparency

Returns:

An rgba style string

Type
string

hsvToRgb(Number, Number, Number)

Source:

Converts an HSV color value to RGB. Conversion formula adapted from http://en.wikipedia.org/wiki/HSV_color_space. Assumes h, s, and v are contained in the set [0, 1] and returns r, g, and b in the set [0, 1].

Parameters:
Name Type Description
Number

h The hue

Number

s The saturation

Number

v The value

Returns:

Array The RGB representation

invertObject(obj) → {Object}

Source:

A temporary shim to invert an object, flipping keys and values

Parameters:
Name Type Description
obj Object

Some object where the values are unique

Returns:

An inverted object where the values of the original object are the keys of the new object

Type
Object

isNewerVersion(v0, v1) → {Boolean}

Source:

Return whether or not a version (v1) is more advanced than some other version (v0) Supports numeric or string version numbers

Parameters:
Name Type Description
v0 Number | String
v1 Number | String
Returns:
Type
Boolean

isObjectEmpty(obj) → {Boolean}

Source:

A simple function to test whether or not an Object is empty

Parameters:
Name Type Description
obj Object

The object to test

Returns:

Is the object empty?

Type
Boolean

loadFont(fontName, callback)

Source:
Deprecated:
  • since 0.6.4, to be removed in 0.8.x

Load font, and perform a callback once the font has been rendered

Parameters:
Name Type Description
fontName
callback

(async) loadTemplates(paths) → {Promise}

Source:

Load and cache a set of templates by providing an Array of paths

Parameters:
Name Type Description
paths Array
Returns:
Type
Promise

(async) loadTexture(src, fallback) → {PIXI.Texture}

Source:

Load a single texture and return a Promise which resolves once the texture is ready to use

Parameters:
Name Type Description
src string

The requested texture source

fallback string

A fallback texture to use if the requested source is unavailable or invalid

Returns:
Type
PIXI.Texture

mergeObject(original, other, insert, overwrite, inplace, enforceTypes, _d) → {Object}

Source:

Update a source object by replacing its keys and values with those from a target object.

Parameters:
Name Type Description
original Object

The initial object which should be updated with values from the target

other Object

A new object whose values should replace those in the source

insert boolean

Control whether to insert new parent objects in the structure which did not previously exist in the source object.

overwrite boolean

Control whether to replace existing values in the source, or only merge values which do not exist in the source.

inplace boolean

Update the values of original inplace? Otherwise duplicate the original and return a safe copy.

enforceTypes boolean

Enforce that the type of an inner value in the source object match the type of the new value. Default is false for now, but should be true in the future.

_d number

A privately used parameter to track recursion depth

Returns:

The original source object including updated, inserted, or overwritten records.

Type
Object

randomID(length) → {string}

Source:

Generate a random ID Generate random number and convert it to base 36 and remove the '0.' at the beginning As long as the string is not long enough, generate more random data into it Use substring in case we generated a string with a length higher than the requested length

Parameters:
Name Type Default Description
length number 10

The length of the random ID to generate

Returns:

Return a string containing random letters and numbers

Type
string

readTextFromFile(file) → {Promise.<String>}

Source:

Read text data from a user provided File object

Parameters:
Name Type Description
file File

A File object

Returns:

A Promise which resolves to the loaded text data

Type
Promise.<String>

renderTemplate(path, data) → {Promise.<HTMLElement>}

Source:
See:

Get and render a template using provided data and handle the returned HTML Support asynchronous file template file loading with a client-side caching layer

Allow resolution of prototype methods and properties since this all occurs within the safety of the client.

Parameters:
Name Type Description
path String

The file path to the target HTML template

data Object

A data object against which to compile the template

Returns:

Returns the rendered HTML

Type
Promise.<HTMLElement>

rgbToHex(rgb) → {Number}

Source:

Converts a color as an [R, G, B] array of normalized floats to a hexadecimal number.

Parameters:
Name Type Description
rgb Array.<Number>

Array of numbers where all values are normalized floats from 0.0 to 1.0.

Returns:

Number in hexadecimal.

Type
Number

rgbToHsv(Number, Number, Number)

Source:

Converts an RGB color value to HSV. Conversion formula adapted from http://en.wikipedia.org/wiki/HSV_color_space. Assumes r, g, and b are contained in the set [0, 1] and returns h, s, and v in the set [0, 1].

Parameters:
Name Type Description
Number

r The red color value

Number

g The green color value

Number

b The blue color value

Returns:

Array The HSV representation

saveDataToFile(data, type, filename)

Source:

Export data content to be saved to a local file

Parameters:
Name Type Description
data String

Data content converted to a string

type String

The type of

filename String

The filename of the resulting download

setProperty(object, key, value) → {Boolean}

Source:

A helper function which searches through an object to assign a value using a string key This string key supports the notation a.b.c which would target object[a][b][c]

Parameters:
Name Type Description
object Object

The object to update

key String

The string key

value

The value to be assigned

Returns:

A flag for whether or not the object was updated

Type
Boolean

(async) srcExists(src) → {boolean}

Source:

Test whether a file source exists by performing a HEAD request against it

Parameters:
Name Type Description
src string

The source URL or path to test

Returns:

Does the file exist at the provided url?

Type
boolean

timeSince(timeStamp) → {string}

Source:

Express a timestamp as a relative string

Parameters:
Name Type Description
timeStamp Date
Returns:
Type
string

Events

{KeyEvent} event The original keydown event

Source:

Handle Key Down event for Push-To-Talk When the right key is pressed, prevents the event from being propagated and pushes the PTT

{KeyEvent} event The original keyup event

Source:

Handle Key Up event for Push-To-Talk When the right key is released, prevents the event from being propagated and releases the PTT

{MouseEvent} event The original mousedown event

Source:

Handle Mouse Down event for Push-To-Talk Pushes the PTT when the right button is pressed

{MouseEvent} event The original mouseup event

Source:

Handle Mouse Up event for Push-To-Talk Releases the PTT when the right button is released