generated from League-of-Foundry-Developers/FoundryVTT-Module-Template
-
Notifications
You must be signed in to change notification settings - Fork 0
Optional Module Functionality
Lich edited this page Dec 6, 2023
·
2 revisions
When the Boneyard Action Prefabs module is present and enabled, measured template documents have two additional utility methods made available for streamlining use of Action Prefabs: actionOnTokens
and actionOnTokenActors
. These methods take one or more Action instances and resolve them on the respective document types of all tokens that collide with a template.
// If Action Prefabs module is present, add utility functions to run actions
if (game.modules.get('boneyard-action-prefabs')?.active) {
/**
* Resolve Action Prefabs on tokens colliding with template.
* @param {Action|Action[]} actions Action instances to resolve on the documents of the colliding tokens.
* @param {object} [options] Options to configure how collision is calculated.
* @param {number} [options.tolerance] Percentage of overlap needed to be considered inside the template.
* @param {string} [options.collisionMethod] Type of collision detection method to use.
* @param {boolean} [options.considerTemplateRatio] Whether to account for the ratio of the intersection and template areas.
* @param {string} [options.tokenCollisionShape] What shape type to use for the token's collision area.
*/
this.actionOnTokens = async function (actions, options) {
for (const token of this.getTokens(options)) await Boneyard.ActionPrefabs.resolve(token, actions);
};
/**
* Resolve Action Prefabs on actors of tokens colliding with template.
* @param {Action|Action[]} actions Action instances to resolve on the actor documents of the colliding tokens.
* @param {object} [options] Options to configure how collision is calculated.
* @param {number} [options.tolerance] Percentage of overlap needed to be considered inside the template.
* @param {string} [options.collisionMethod] Type of collision detection method to use.
* @param {boolean} [options.considerTemplateRatio] Whether to account for the ratio of the intersection and template areas.
* @param {string} [options.tokenCollisionShape] What shape type to use for the token's collision area.
*/
this.actionOnTokenActors = async function (actions, options) {
for (const token of this.getTokens(options)) await Boneyard.ActionPrefabs.resolve(token.actor, actions);
};
}