Namespaces
-
abstract
Warp Gate classes suitable for extension
-
-
crosshairs
Crosshairs methods
-
-
event
Event system API functions.
-
-
grid
Helper functions related to grid-centric canvas operations
-
-
plugin
Methods intended for warp gate "pylons" (e.g. Warp Gate-dependent modules)
-
-
util
Utility functions for common queries and operations
-
Members
-
<static, readonly> CONST :string
-
Description
Constants and enums for use in embedded shorthand fields
Properties
Name Type Default Description DELETE
string delete Instructs warpgate to delete the identified embedded document. Used in place of the update or create data objects.
Details
-
<static> EVENT :string
-
Description
Event name constants for use with the
warpgate.event
system.Properties
Name Type Default Description PLACEMENT
string wg_placement After placement is chosen
SPAWN
string wg_spawn After each token has been spawned and fully updated
DISMISS
string wg_dismiss After a token has been dismissed via warpgate
REVERT
string wg_revert After a token has been fully reverted
MUTATE
string wg_mutate After a token has been fully modified
MUTATE_RESPONSE
string wg_response_mutate Feedback of mutation acceptance/rejection from the remote owning player in the case of an "unowned" or remote mutation operation
REVERT_RESPONSE
string wg_response_revert Feedback of mutation revert acceptance/rejection from the remote owning player in the case of an "unowned" or remote mutation operation
Details
-
<static, readonly> USERS :Array.<string>
-
Description
Helper enums for retrieving user IDs
Properties
Name Type Description ALL
Array.<string> All online users
SELF
Array.<string> The current user
GM
Array.<string> All online GMs
PLAYERS
Array.<string> All online players (non-gms)
Details
Methods
-
<async, static> buttonDialog( data [, direction ] )
-
Description
Helper function for quickly creating a simple dialog with labeled buttons and associated data. Useful for allowing a choice of actors to spawn prior to
warpgate.spawn
.Parameters
Name Type Attributes Default Description data
Object Name Type Attributes Description buttons
Array.<{label: string, value: *}> title
string <optional> content
string <optional> options
Object <optional> direction
string <optional> 'row' 'column' or 'row' accepted. Controls layout direction of dialog.
Details
-
<async, static> dismiss( tokenId [, sceneId [, onBehalf ] ] )
-
Description
Deletes the specified token from the specified scene. This function allows anyone to delete any specified token unless this functionality is restricted to only owned tokens in Warp Gate's module settings. This is the same function called by the "Dismiss" header button on owned actor sheets.
Parameters
Name Type Attributes Default Description tokenId
string sceneId
string <optional> canvas.scene.id Needed if the dismissed token does not reside on the currently viewed scene
onBehalf
string <optional> game.user.id Impersonate another user making this request
Details
-
<async, static> menu( [ prompts [, config ] ] ) → {Promise.<MenuResult>}
-
Description
Advanced dialog helper providing multiple input type options as well as user defined buttons.
Parameters
Name Type Attributes Description prompts
Object <optional> Name Type Attributes Description inputs
Array.<MenuInput> <optional> buttons
Array.<MenuButton> <optional> If no default button is specified, the last button provided will be set as default
config
MenuConfig <optional> Returns
Examples
const results = await warpgate.menu({ inputs: [{ label: 'My Way', type: 'radio', options: 'group1', }, { label: 'The Highway', type: 'radio', options: 'group1', },{ label: 'Agree to ToS 😈', type: 'checkbox', options: true, },{ type: 'select', label: 'Make it a combo?', options: [ {html: 'Yes ✅', value: {combo: true, size: 'med'}}, {html: 'No ❌', value: {combo: false}, selected:true}, {html: 'Super Size Me!', value: {combo: true, size: 'lg'}} ], }], buttons: [{ label: 'Yes', value: 1, callback: () => ui.notifications.info('Yes was clicked'), }, { label: 'No', value: 2 }, { label: '<strong>Maybe</strong>', value: 3, default: true, callback: (results) => { results.inputs[3].freebies = true; ui.notifications.info('Let us help make your decision easier.') }, }, { label: 'Eventually', value: 4 }] },{ title: 'Choose Wisely...', //checkedText: true, //Swap true/false output to label/empty string render: (...args) => { console.log(...args); ui.notifications.info('render!')}, options: { width: '100px', height: '100%', } }) console.log('results', results) // EXAMPLE OUTPUT // Ex1: Default state (Press enter when displayed) // ------------------------------- // Foundry VTT | Rendering Dialog // S.fn.init(3) [div.dialog-content, text, div.dialog-buttons] // render! // Let us help make your decision easier. // results { // "inputs": [ // false, // false, // true, // { // "combo": false, // "freebies": true // } // ], // "buttons": 3 // } // // Ex 2: Output for selecting 'My Way', super sizing // the combo, and clicking 'Yes' // ------------------------------- // Foundry VTT | Rendering Dialog // S.fn.init(3) [div.dialog-content, text, div.dialog-buttons] // render! // Yes was clicked // results { // "inputs": [ // true, // false, // true, // { // "combo": true, // "size": "lg" // } // ], // "buttons": 1 // }
Details
-
<async, static> mutate( tokenDoc [, updates [, callbacks [, options ] ] ] ) → {Promise.<(MutationData|false)>}
-
Description
Given an update argument identical to
warpgate.spawn
and a token document, will apply the changes listed in the updates and (by default) store the change delta, which allows these updates to be reverted. Mutating the same token multiple times will "stack" the delta changes, allowing the user to remove them as desired, while preserving changes made "higher" in the stack.Parameters
Name Type Attributes Description tokenDoc
TokenDocument Token document to update, does not accept Token Placeable.
updates
Shorthand <optional> callbacks
Object <optional> Two provided callback locations: delta and post. Both are awaited.
Name Type Attributes Description delta
PostDelta <optional> post
PostMutate <optional> options
WorkflowOptions | MutationOptions <optional> Returns
Details
-
<static> mutationStack( tokenDoc ) → {MutationStack}
-
Description
Factory method for creating a new mutation stack class from the provided token document
Parameters
Name Type Description tokenDoc
TokenDocument Returns
Details
-
<async, static> revert( tokenDoc [, mutationName [, options ] ] ) → {Promise.<(MutationData|undefined)>}
-
Description
Will peel off the last applied mutation change from the provided token document
Parameters
Name Type Attributes Description tokenDoc
TokenDocument Token document to revert the last applied mutation.
mutationName
String <optional> Specific mutation name to revert. optional.
options
WorkflowOptions <optional> Returns
Details
-
<async, static> spawn( spawnName [, updates [, callbacks [, options ] ] ] ) → {Promise.<Array.<String>>}
-
Description
The primary function of Warp Gate. When executed, it will create a custom MeasuredTemplate that is used to place the spawned token and handle any customizations provided in the
updates
object.warpgate#spawn
will return a Promise that can be awaited, which can be used in loops to spawn multiple tokens, one after another (or use theduplicates
options). The player spawning the token will also be given Owner permissions for that specific token actor. This means that players can spawn any creature available in the world.Parameters
Name Type Attributes Description spawnName
String | PrototypeTokenDocument Name of actor to spawn or the actual TokenData that should be used for spawning.
updates
Shorthand <optional> embedded document, actor, and token document updates. embedded updates use a "shorthand" notation.
callbacks
Object <optional> The callbacks object as used by spawn and spawnAt provide a way to execute custom code during the spawning process. If the callback function modifies updates or location, it is often best to do this via
mergeObject
due to pass by reference restrictions.Name Type Attributes Description pre
PreSpawn <optional> post
PostSpawn <optional> show
ParallelShow <optional> options
WarpOptions | SpawningOptions <optional> Returns
Details
-
<async, static> spawnAt( spawnLocation, protoData [, updates [, callbacks [, options ] ] ] ) → {Promise.<Array.<string>>}
-
Description
An alternate, more module friendly spawning function. Will create a token from the provided token data and updates at the designated location.
Parameters
Name Type Attributes Description spawnLocation
Object Centerpoint of spawned token
protoData
String | PrototypeTokenData | TokenData | PrototypeTokenDocument Any token data or the name of a world-actor. Serves as the base data for all operations.
updates
Shorthand <optional> callbacks
Object <optional> see
warpgate.spawn
Name Type Attributes Description pre
PreSpawn <optional> post
PostSpawn <optional> options
SpawningOptions <optional> Modifies behavior of the spawning process.
Returns
Details
-
<async, static> wait( ms )
-
Description
Helper function. Waits for a specified amount of time in milliseconds (be sure to await!). Useful for timings with animations in the pre/post callbacks.
Parameters
Name Type Description ms
Number Time to delay, in milliseconds
Returns
Details