Skip to main content

Programmatic API

The module exposes an API on game.modules.get("pathmuncher").api once Foundry's ready hook has fired. Pathmuncher does not fire any hooks of its own.

Members​

MemberPurpose
PathmuncherImporterThe importer window. PathmuncherImporter.open(actor) opens it for an actor, or brings it to the front if it is already open
PathmuncherThe import engine: new Pathmuncher(actor, options) (see below)
PetShopCreates and updates familiars from a build
ImportReportDialogThe import notes window. ImportReportDialog.show(report) shows notes from pathmuncher.getImportReport()
BFFBuilderBuilds a build's animal companions and eidolon with the PF2e Companion Compendia module (see below)
EidolonBuilderAppThe eidolon builder window. EidolonBuilderApp.open(eidolon) opens it for an eidolon
EidolonEditorThe eidolon builder's choices, preview and changes, without the window
CompendiumMatcherFinds Pathbuilder names in the compendiums Pathmuncher searches
CompendiumSelectorThe Compendium Lookups window
SeasoningName-mapping helpers, between Pathbuilder names and Foundry names
Pf2eRulesPathmuncher's wrapper around the system's rule code. Pf2eRules.missing() lists any parts the system no longer provides
dataThe name-mapping tables: feats, generateFeatMap(pbName?), equipment(pbName?), spellRename(pbName) and restrictedEquipment
utilsModule utilities, such as setting(key), getFlags(actor) and getOrCreateFolder(...)
CONSTANTSModule constants, including the default compendium lookups (CORE_COMPENDIUM_MAPPINGS) and import options (ACTOR_FLAGS)

Opening the importer​

const { PathmuncherImporter } = game.modules.get("pathmuncher").api;
PathmuncherImporter.open(actor);

Importing without the window​

Pathmuncher runs an import without the importer window. This is the same sequence the window uses:

const { Pathmuncher } = game.modules.get("pathmuncher").api;

const pathmuncher = new Pathmuncher(actor, {
addMoney: false, // any import option, all true by default
});

// load the build: from Pathbuilder by export ID...
await pathmuncher.fetchPathbuilder("123456");
// ...or from the export's JSON (the whole export, or just its "build")
// pathmuncher.source = Pathmuncher.getBuildFromJson(json);

if (await pathmuncher.processCharacter()) {
await pathmuncher.updateActor();
await pathmuncher.postImportCheck(); // shows the import notes
}

processCharacter() works out the whole build without changing the actor. It returns false if there is no build, or the user cancelled.

updateActor() writes the result to the actor. By default it keeps items the user added by hand; pass { keepItemIds: [...] } to keep only those. findHandAddedItems() lists the hand-added items the import would otherwise replace.

getImportReport() returns the import notes as data, instead of showing them.

Options​

The import options are the keys of CONSTANTS.ACTOR_FLAGS: addName, addClass, addAncestry, addHeritage, addBackground, addDeity, addFeats, addLores, addSpells, adjustBlendedSlots, addFormulas, addFamiliars, addEquipment, addWeapons, addArmor, addTreasure and addMoney. See Import Options for what each one does.

Familiars are not created by updateActor(). The importer window creates them afterwards with PetShop:

const { PetShop } = game.modules.get("pathmuncher").api;
const petShop = new PetShop({ type: "familiar", parent: actor, pathbuilderJson: pathmuncher.source });
await petShop.processPets();
await petShop.addPetEffects();

Callbacks​

These options let you answer the questions the importer window asks. Each is optional.

OptionCalled withWithout it
statusCallback(step, total, type, prefixLabel)Progress through the importNo progress is reported
resolveDeityConflict(conflict)The deity's choices the build breaksThe system asks for those choices
resolveMissingCore(missing)The ancestry, heritage, background or class no compendium hasThey are skipped, and listed in the import notes
resolveUnansweredChoices(choices)Choices the build does not recordThe system asks for each one as the item is created
resolveAmmunition(request)Ammunition to share between several gunsThe ammunition is listed in the import notes

Companions and eidolons​

The importer window builds companions after the character, with BFFBuilder. Without the window, build them after updateActor():

const { BFFBuilder } = game.modules.get("pathmuncher").api;
if (BFFBuilder.active) {
const bff = new BFFBuilder({ pathmuncher, master: actor });
await bff.build();
}
OptionCalled withWithout it
resolveCompanionActor({ master, pet, name, candidates })A companion with no character linked yet, and the characters it could go to. Return { create: true }, { actor }, or null to leave it outA new character is made
reviewEidolon({ eidolon, guessed })The eidolon once it is made, and the choices made by default. Return whether its choices were madeThe default choices are listed in the import notes

Matching compendium items​

CompendiumMatcher finds a Pathbuilder name in the compendiums Pathmuncher searches for one kind of item, using the Compendium Lookups settings:

const { CompendiumMatcher } = game.modules.get("pathmuncher").api;
const matcher = new CompendiumMatcher({ type: "feats" });
await matcher.loadCompendiums();
const match = matcher.getMatch("Power Attack", "Power Attack");
// match.pack is the compendium, match.i its index entry

The types are the keys of CONSTANTS.CORE_COMPENDIUM_MAPPINGS.