Realm VTT | Blog

Write Custom Macros in Campaigns

Written by Sean Schnell | Sep 10, 2025 4:18:59 PM

Macros are powerful custom automation scripts that Game Masters can create in their Realm VTT Campaigns. With Macros, you can create quick buttons in the chat to execute a variety of ruleset functions, or drag them to your Hot Bar to execute at any time.

A macro is a JavaScript snippet that can interact with your campaign through Realm VTT's comprehensive API. They allow you to:

  • Automate dice rolls with custom modifiers and difficulty classes
  • Apply effects to tokens automatically
  • Create custom mechanics tailored to your campaign
  • Speed up gameplay by reducing manual tasks

Getting Started

To access Macros, simply click View > Macros in your campaign interface. From there, you can:

  • Create new macros with the "Add New Macro" button
  • Search your macro library for this campaign
  • Edit existing macros by clicking on them
  • Send macros to the chat or drag them directly onto a token, or the Hot Bar for executing later
  • Right-click for options like rename, copy, and delete

Rich Text Integration

Macros seamlessly integrate with Realm VTT's rich text system. You can embed macro code directly in your campaign notes, character sheets, or chat messages. When other players see your rich text content, executable macros appear as interactive buttons they can click to run.

D&D 5e Macro Tips

Here are two quick example macros that might be useful for your D&D 5e campaigns.

Saving Throws with DC

// Saving Throw example for Wisdom DC 15 
rollSavingThrow("Wisdom", 15);

Skill Check with DC

// Skill Check example for Athletics DC 10
rollSkillCheck("Athletics", 10);

Macro Tips

  • Name your macros descriptively - "Fireball Damage" is better than "Macro1"
  • Test macros thoroughly before using them in a live session
  • Share useful macros with your fellow Game Masters on the Forum or the Discord
  • Curious about how the D&D 5e system executes code under the hood? Create a "copy" of the 5e ruleset with the Ruleset Editor to view the code and write macros in a similar manner.
    • The "Common Script" under the "Settings -> Additional Settings" of the Ruleset Editor contains the functions that all macros have access to for that ruleset (such as the rollSavingThrow and rollSkillCheck functions above for 5e.)
  • Check the API documentation for more information at https://www.realmvtt.com/wiki/ruleset-editor-and-api