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
| Member | Purpose |
|---|---|
PathmuncherImporter | The importer window. PathmuncherImporter.open(actor) opens it for an actor, or brings it to the front if it is already open |
Pathmuncher | The import engine: new Pathmuncher(actor, options) (see below) |
PetShop | Creates and updates familiars from a build |
ImportReportDialog | The import notes window. ImportReportDialog.show(report) shows notes from pathmuncher.getImportReport() |
BFFBuilder | Builds a build's animal companions and eidolon with the PF2e Companion Compendia module (see below) |
EidolonBuilderApp | The eidolon builder window. EidolonBuilderApp.open(eidolon) opens it for an eidolon |
EidolonEditor | The eidolon builder's choices, preview and changes, without the window |
CompendiumMatcher | Finds Pathbuilder names in the compendiums Pathmuncher searches |
CompendiumSelector | The Compendium Lookups window |
Seasoning | Name-mapping helpers, between Pathbuilder names and Foundry names |
Pf2eRules | Pathmuncher's wrapper around the system's rule code. Pf2eRules.missing() lists any parts the system no longer provides |
data | The name-mapping tables: feats, generateFeatMap(pbName?), equipment(pbName?), spellRename(pbName) and restrictedEquipment |
utils | Module utilities, such as setting(key), getFlags(actor) and getOrCreateFolder(...) |
CONSTANTS | Module 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.
| Option | Called with | Without it |
|---|---|---|
statusCallback(step, total, type, prefixLabel) | Progress through the import | No progress is reported |
resolveDeityConflict(conflict) | The deity's choices the build breaks | The system asks for those choices |
resolveMissingCore(missing) | The ancestry, heritage, background or class no compendium has | They are skipped, and listed in the import notes |
resolveUnansweredChoices(choices) | Choices the build does not record | The system asks for each one as the item is created |
resolveAmmunition(request) | Ammunition to share between several guns | The 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();
}
| Option | Called with | Without 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 out | A new character is made |
reviewEidolon({ eidolon, guessed }) | The eidolon once it is made, and the choices made by default. Return whether its choices were made | The 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.