Skip to content

Macro API

PrinceWitherdick edited this page Oct 25, 2026 · 1 revision

Macro API

The module puts a small API on its module entry once the world is ready, for macros and other modules.

const api = game.modules.get("relationship-map-pwd").api;
Call What it does
api.open() Opens the map you were last on, the same as the Relationship Maps button. In a world with no collection yet, it asks for a name for the first one.
api.open("The Valley") Opens a collection by its name or its id. If nothing matches, it opens the map you were last on.
api.choose() Shows the Collections list and opens the one you pick.

Both open and choose are async.

Examples

A hotbar macro that opens one collection:

game.modules.get("relationship-map-pwd").api.open("The Valley");

A macro that asks which collection to open:

game.modules.get("relationship-map-pwd").api.choose();

Notes

  • The names here are collection names, not the names of the maps (tabs) inside a collection. Use the tabs to move between maps once the window is open.

  • In a world with no collection yet, a player who can't make one is told to ask the GM instead of being asked for a name.

  • api is set during Foundry's ready hook. Code that runs earlier than that should wait for it:

    Hooks.once("ready", () => {
      const api = game.modules.get("relationship-map-pwd")?.api;
      // ...
    });

Clone this wiki locally