The Magic of Automation
Imagine having a tireless assistant who remembers every rule, calculates every modifier, and handles all the bookkeeping while you focus on storytelling. That's what macros and automation bring to Foundry VTT. They're like teaching your game table to run itself!
Think of macros as magical spells you create once and cast whenever needed. Need to roll initiative for 20 goblins? One click. Want to apply torch light to selected tokens? One click. Need to whisper a mysterious message to specific players? One click. You're not learning to code - you're learning to delegate!
The Automation Ecosystem
Your First Macro: Baby Steps to Power
Let's create a simple macro that makes your GM life easier!
Essential Macros Every GM Needs
Here's your macro starter kit - simple but powerful tools for common tasks!
Chat Commands: Your Quick Access Toolbar
Building Complex Macros: From Simple to Spectacular
Let's evolve from basic macros to powerful automation!
Active Effects: Living Buffs and Debuffs
Active Effects are like enchantments that know their own rules!
Example: Bless Spell Effect
- Effect: +1d4 to attack rolls and saving throws
- Duration: 10 rounds (1 minute)
- Visual: Golden glow on token
- Automation: Automatically adds to all rolls
Practical Macro Library
Copy these tested macros for instant GM power-ups!
The "Oh No!" Emergency Kit
1. Heal All PCs
// Emergency healing for all PCs
const pcs = game.actors.filter(a => a.hasPlayerOwner);
pcs.forEach(pc => {
const hp = pc.system.attributes.hp;
pc.update({"system.attributes.hp.value": hp.max});
});
ui.notifications.info("All PCs healed to full!");
2. Dramatic Lighting Change
// Sudden darkness falls!
await canvas.scene.update({darkness: 0.9});
ChatMessage.create({
content: "Darkness Falls!
The lights suddenly dim...
",
speaker: {alias: "GM"}
});
3. Roll Stealth for All Enemies
// Mass stealth check
const hostiles = canvas.tokens.placeables.filter(t =>
t.document.disposition === -1
);
hostiles.forEach(token => {
const roll = new Roll("1d20 + @skills.ste.mod",
token.actor.getRollData());
roll.toMessage({
speaker: {alias: token.name},
flavor: "Stealth Check",
whisper: [game.user.id]
});
});
4. Teleport Selected Tokens
// Click to teleport selected tokens
const tokens = canvas.tokens.controlled;
if (tokens.length === 0) return ui.notifications.warn("Select tokens!");
ui.notifications.info("Click destination...");
const location = await canvas.tokens.targetPosition();
tokens.forEach(t => t.document.update(location));
Module Automation: Supercharge Your Game
Modules add incredible automation capabilities. Here are the game-changers:
Practice Exercise: Build Your Automation Suite
Beginner Challenge: Basic Macro Set
- Welcome Message: Create a macro that displays a dramatic welcome when sessions start
- Rest Reminder: A macro that asks "Short or Long rest?" and heals accordingly
- Torch Toggle: One-click to add/remove torch light from selected token
- Initiative Cleaner: Remove all NPCs from combat tracker
- Inspiration Giver: Award inspiration with fanfare
Intermediate Challenge: Scene Automation
- Day/Night Cycle: Macro that toggles between day and night lighting
- Weather System: Random weather generator with scene effects
- Trap Activator: Macro that triggers trap effects on selected tokens
- Mass Teleport: Move all party tokens to clicked location
- Combat Prep: Auto-setup macro that rolls initiative for all tokens
Advanced Challenge: Complete Automation
- Smart Healing: Heals most injured PC first, announces in chat
- Condition Manager: Apply/remove conditions with duration tracking
- Loot Generator: Creates treasure based on CR and party size
- NPC Generator: Creates complete NPC with stats and description
- Scene Narrator: Automated descriptions based on time/weather
Debugging Your Macros
When macros go wrong (and they will!), here's how to fix them:
Common Issues and Solutions
- Nothing Happens: Check the console (F12) for error messages
- Wrong Target: Ensure tokens are selected or targeted
- Permissions: Some actions need GM privileges
- Timing Issues: Use
awaitfor asynchronous actions - Scope Problems: Variables might not be accessible where you think
Debug Helper Macro
// Debug helper - shows useful info
console.log("=== DEBUG INFO ===");
console.log("Selected Tokens:", canvas.tokens.controlled);
console.log("Targeted Tokens:", game.user.targets);
console.log("Active Scene:", canvas.scene.name);
console.log("Current User:", game.user.name);
console.log("Combat Active:", game.combat?.active);
ui.notifications.info("Check console for debug info (F12)");
Real GM Automation Stories
The One-Button Boss Fight
"I created a macro that transforms the throne room into a battle arena - walls rise, lighting changes to red, boss music starts, and reinforcements spawn. My players' jaws dropped when I just said 'You shouldn't have insulted the king' and pressed one button!" - GM Patricia
The Living World
"My world has a complete day/night cycle with shop hours. NPCs 'close' their shops at night (tokens disappear), street lamps light up, and guard patrols activate. It runs automatically based on game time. Players plan heists around it!" - GM Roberto
The Personalized Experience
"Each player has custom macros on their hotbar. The barbarian has 'RAGE!' that applies all effects and plays metal music. The wizard has a spell component tracker. They love their personalized buttons!" - GM Kim
Macro Best Practices
Writing Good Macros
- Comment Your Code: Future you will thank present you
- Error Handling: Check if tokens exist before using them
- User Feedback: Use notifications to confirm actions
- Keep It Simple: Many simple macros > one complex macro
- Test Thoroughly: Try edge cases before game time
Organizing Your Macros
- Naming Convention: "GM - Combat - Roll Initiative"
- Color Coding: Red for combat, blue for utility, etc.
- Folders: Group related macros together
- Documentation: Keep a journal entry with macro descriptions
- Backup: Export important macros regularly
What's Next?
You've learned to teach Foundry to work for you! Your macros and automation handle the mechanical heavy lifting while you focus on storytelling and player engagement. Every click saved is more time for epic moments.
In our next lesson, we'll explore Audio and Music - creating soundscapes that transport players into your world!