API Documentation

This document details the methods available through the Campaign Codex API.


Accessing the API

To use the API commands, you must first get the API object. This can be done in a macro or via the developer console.

const campaignCodexAPI = game.modules.get('campaign-codex')?.api;

API Methods

convertJournalToCCSheet

Converts a standard Foundry VTT Journal Entry, including those with multiple text pages, into one or more Campaign Codex sheets of a specified type.

Syntax

campaignCodexAPI.convertJournalToCCSheet(uuid, type, pagesToSeparateSheets);

Parameters

  • uuid
    • Type: String
    • Description: The UUID of the Journal Entry to be converted.
  • type
    • Type: String
    • Description: The destination sheet type.
    • Valid Values: "location", "npc", "region", "shop", "group", "tags"
  • pagesToSeparateSheets
    • Type: Boolean
    • Description:
      • If true, a new Campaign Codex sheet (of the specified type) will be created for each individual page within the source Journal Entry.
      • If false or omitted, a single Campaign Codex sheet will be created, with the content of all journal pages combined.

exportToObsidian

Exports your Campaign Codex content into a .zip archive containing Markdown (.md) files, suitable for use in Obsidian or other Markdown editors.

Syntax

campaignCodexAPI.exportToObsidian();

Parameters

This method takes no parameters.


openTOCSheet

Opens the main Table of Contents (ToC) sheet for the Campaign Codex.

Syntax

campaignCodexAPI.openTOCSheet(tab);

Parameters

type

  • Tab: String
  • Description: The tab to open the ToC at.
  • Valid Values: "locations", "npcs", "regions", "shops", "groups", "tags", “quests”