Hooks
Hero Mancer fires its hooks with Hooks.callAll under the heroMancer. prefix. Listen with Hooks.on, for example Hooks.on("heroMancer.Created", ({ actor }) => { ... }). Public methods are listed in the API reference.
Fired hooks
Section titled “Fired hooks”| Hook | When it fires | Callback arguments |
|---|---|---|
heroMancer.Ready | During Foundry’s ready hook, after Hero Mancer registers its sockets and listeners. | MODULE |
heroMancer.documentsReady | Compendium entries for an item type have been fetched and sorted. | type, entries, promises |
heroMancer.WizardOpened | The wizard window finishes its first render. | { app, fsm } |
heroMancer.PreCreate | The base actor exists, before its items and advancements are applied. | { actor, draft } |
heroMancer.Created | The character is fully built. | { actor } |
heroMancer.ApprovalSubmitted | A draft is submitted to the approval queue. | { flagData } |
heroMancer.ApprovalApproved | The current user’s submission was approved. | { pageId, payload, characterName, actorUuid } |
heroMancer.ApprovalRejected | The current user’s submission was rejected. | { pageId, reason, payload } |
heroMancer.ApprovalReceived | A submission page is added to the pending queue, including startup recovery and archive restores. | { page, flagData, restored } |
heroMancer.ApprovalResolved | A pending submission is approved or rejected, before its page is archived or deleted. | { pageId, outcome, flagData, rejectionReason } |
heroMancer.LevelUpStarted | Level-up mode opens for a character, before the window finishes rendering. | { actor, app } |
heroMancer.LevelUpCompleted | A level-up is committed to the actor. | { actor, newLevel, spellcasting, details } |
Payloads
Section titled “Payloads”heroMancer.documentsReady passes a promises array. Push promises to it to hold the final sort until your async changes to entries finish.
draft on heroMancer.PreCreate is the advancement pick map. If the build fails after this hook, the actor is deleted and heroMancer.Created does not fire.
payload on heroMancer.ApprovalApproved is always null, so use actorUuid to find the created actor. On heroMancer.ApprovalRejected, payload is the submission as a JSON string.
restored on heroMancer.ApprovalReceived is true only for pages restored from the archive.
heroMancer.LevelUpCompleted carries two detail objects. spellcasting compares the actor before and after the level, with firstCaster, previousMaxSpellLevel, newMaxSpellLevel, previousCantrips, and newCantrips. details lists what the level granted, with className, hitPoints, abilities, and items. newLevel is the new level in the class that gained the level, not the character’s total level.