Repository navigation
Example Macros
Ken Dearman edited this page Feb 26, 2026
·
3 revisions
The following are example macros using the existing API (which is still very basic at this stage).
Change the visageId = "zU9sLxeFW5uwJDnd" to the ID of your Visage.
/**
* Apply Visage to selected tokens
*/
async function applyVisage() {
// 1. Check if the Visage API is available
const visageApi = game.modules.get("visage")?.api;
if (!visageApi) {
ui.notifications.error("The Visage module is not active or the API is unavailable.");
return;
}
// 2. Get the currently selected tokens
const tokens = canvas.tokens.controlled;
if (tokens.length === 0) {
ui.notifications.warn("Please select at least one token.");
return;
}
// 3. The unique ID of the Visage from your JSON
const visageId = "zU9sLxeFW5uwJDnd";
// 4. Apply the Visage to all selected tokens
for (const token of tokens) {
try {
// The apply method accepts either the token document, token object, or token ID
await visageApi.apply(token.id, visageId);
console.log(`Visage | Successfully applied Visage to ${token.name}`);
} catch (err) {
console.error(`Visage | Failed to apply Visage to ${token.name}`, err);
}
}
}
applyVisage();/**
* Return selected tokens to their Full Default Visage
*/
async function revertToDefault() {
// 1. Check if the Visage API is available
const visageApi = game.modules.get("visage")?.api;
if (!visageApi) {
ui.notifications.error("The Visage module is not active or the API is unavailable.");
return;
}
// 2. Get the currently selected tokens
const tokens = canvas.tokens.controlled;
if (tokens.length === 0) {
ui.notifications.warn("Please select at least one token to revert.");
return;
}
// 3. Revert each token
for (const token of tokens) {
try {
// The revert method strips away the Visage stack and restores the base token
await visageApi.revert(token.id);
console.log(`Visage | Successfully reverted ${token.name} to default.`);
} catch (err) {
console.error(`Visage | Failed to revert ${token.name}`, err);
}
}
}
revertToDefault();- Home
-
Getting Started
- Tutorial 1: Creating a Local Identity
- Tutorial 2: Creating a Global Overlay
- Tutorial 3: Lighting & Sequencer Audio
- Tutorial 4: Sequencer Visuals
- Tutorial 5: Using Wildcards
- Tutorial 6: Attribute Conditions
- Tutorial 7: Status / Active Effect Conditions
- Tutorial 8: Event Conditions
- Tutorial 9: Library Actions
- Tutorial 10: Automation Strategy
- Game Settings
- The Visage Selector HUD
- The Visage Library
- The Visage Editor
- System & Module Compatibility Notes
- Advanced Features
- Example Macros