Macros and Automation in Foundry VTT

Your Digital Game Assistant

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

graph TB A[Automation in Foundry] --> B[Simple Macros] A --> C[Chat Commands] A --> D[Script Macros] A --> E[Active Effects] A --> F[Module Automation] B --> B1[Dice Rolls] B --> B2[Token Actions] B --> B3[Quick Messages] B --> B4[Scene Controls] C --> C1[/roll Commands] C --> C2[/whisper Messages] C --> C3[/emote Actions] C --> C4[/table Rolls] D --> D1[Complex Actions] D --> D2[Conditional Logic] D --> D3[Multi-step Process] D --> D4[API Integration] E --> E1[Buff/Debuff] E --> E2[Equipment Bonuses] E --> E3[Spell Effects] E --> E4[Conditions] F --> F1[Combat Automation] F --> F2[Item Management] F --> F3[Spell Casting] F --> F4[World Building] style A fill:#2c3e50,stroke:#34495e,stroke-width:3px,color:#fff style B fill:#3498db,stroke:#2980b9,stroke-width:2px,color:#fff style D fill:#e74c3c,stroke:#c0392b,stroke-width:2px,color:#fff style E fill:#27ae60,stroke:#229954,stroke-width:2px,color:#fff style F fill:#9b59b6,stroke:#8e44ad,stroke-width:2px,color:#fff

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!

flowchart LR A[GM Macro Toolkit] --> B[Combat Helpers] A --> C[Scene Management] A --> D[Communication] A --> E[Token Control] B --> B1[Roll Initiative All] B --> B2[End Combat] B --> B3[Apply Damage] B --> B4[Reset HP] C --> C1[Lighting Presets] C --> C2[Weather Toggle] C --> C3[Scene Transitions] C --> C4[Fog Reset] D --> D1[GM Description] D --> D2[Whisper Player] D --> D3[Party Message] D --> D4[Sound Cues] E --> E1[Toggle Visibility] E --> E2[Mass Movement] E --> E3[Apply Conditions] E --> E4[Token Cleanup] style A fill:#2c3e50,stroke:#34495e,stroke-width:3px,color:#fff style B fill:#e74c3c,stroke:#c0392b,stroke-width:2px,color:#fff style C fill:#3498db,stroke:#2980b9,stroke-width:2px,color:#fff style D fill:#27ae60,stroke:#229954,stroke-width:2px,color:#fff style E fill:#f39c12,stroke:#d68910,stroke-width:2px,color:#fff

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!

graph TB A[Active Effects] --> B[Attribute Changes] A --> C[Duration Tracking] A --> D[Conditional Logic] A --> E[Visual Indicators] B --> B1[AC Bonuses] B --> B2[Ability Scores] B --> B3[Damage Resistance] B --> B4[Movement Speed] C --> C1[Rounds] C --> C2[Minutes] C --> C3[Until Rest] C --> C4[Permanent] D --> D1[Only in Sunlight] D --> D2[While Raging] D --> D3[Against Undead] D --> D4[When Bloodied] E --> E1[Token Tint] E --> E2[Status Icons] E --> E3[Auras] E --> E4[Name Changes] style A fill:#27ae60,stroke:#229954,stroke-width:3px,color:#fff style B fill:#3498db,stroke:#2980b9,stroke-width:2px,color:#fff style C fill:#f39c12,stroke:#d68910,stroke-width:2px,color:#fff style D fill:#e74c3c,stroke:#c0392b,stroke-width:2px,color:#fff

Example: Bless Spell Effect

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

  1. Welcome Message: Create a macro that displays a dramatic welcome when sessions start
  2. Rest Reminder: A macro that asks "Short or Long rest?" and heals accordingly
  3. Torch Toggle: One-click to add/remove torch light from selected token
  4. Initiative Cleaner: Remove all NPCs from combat tracker
  5. Inspiration Giver: Award inspiration with fanfare

Intermediate Challenge: Scene Automation

  1. Day/Night Cycle: Macro that toggles between day and night lighting
  2. Weather System: Random weather generator with scene effects
  3. Trap Activator: Macro that triggers trap effects on selected tokens
  4. Mass Teleport: Move all party tokens to clicked location
  5. Combat Prep: Auto-setup macro that rolls initiative for all tokens

Advanced Challenge: Complete Automation

  1. Smart Healing: Heals most injured PC first, announces in chat
  2. Condition Manager: Apply/remove conditions with duration tracking
  3. Loot Generator: Creates treasure based on CR and party size
  4. NPC Generator: Creates complete NPC with stats and description
  5. 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

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

Organizing Your Macros

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!