Skip to content
Idle edited this page Oct 30, 2023 · 9 revisions

API

A series of functions have been exposed to the global

/**
 * Retrieves the API object containing the funtions
 */
game.modules.get('pf2e-toolbelt').api
heroActions: {
    /**
     * creates a Hero Actions table in your world
     * NOTE: should be put into a script macro
     * @returns { Promise<void> }
     */
    createTable,
    /**
     * removes the hero actions from any/all characters in your world,
     * NOTE: should be put into a script macro
     * @returns { Promise<void> }
     */
    removeHeroActions,
    /**
     * @param { CharacterPF2e } actor
     * @returns { { uuid: string; name: string; }[] } the list of hero actions on this character
     */
    getHeroActions,
    /**
     * uses the hero action and spends a hero point
     * @param { CharacterPF2e } actor
     * @param { string } uuid - the uuid of the action
     * @returns { Promise<void> }
     */
    useHeroAction,
    /**
     * @param { string } uuid - the uuid of the action
     * @returns { Promise<{ name: any; description: any; }> } the name and description of the action
     */
    getHeroActionDetails,
    /**
     * @return { Promise<{ uuid: string; name: any; }> | undefined | null } null if an error occurred
     */
    drawHeroAction,
    /**
     * draws as many hero actions as needed to fill the difference between
     * the number of current actions on the character and the number of hero points
     * @param { CharacterPF2e } actor
     * @returns { Promise<void> }
     */
    drawHeroActions,
    /**
     * sends the action description to chat
     * @param { CharacterPF2e } actor
     * @param { string } uuid - the uuid of the action
     * @returns { Promise<void> }
     */
    sendActionToChat,
    /**
     * discards as many action from the character to reach the current number of hero points
     * @param { CharacterPF2e } actor
     * @param { string } uuid - the uuid of the action
     * @returns { Promise<void> }
     */
    discardHeroActions,
    /**
     * starts a trade request, opens a dialog window where the target character,
     * the offered and requested actions can be chosen
     * @param { CharacterPF2e } actor
     */
    tradeHeroAction,
    /**
     * @returns { Promise<RollTable> } the module tries to find in that order:
     * - a table in your world with the UUID specified in the settings
     * - a default `Hero Point Deck` table in your world
     * - the default `Hero Point Deck` from the compendium
     */
    getDeckTable,
}
stances: {
    /**
     * @param { object } stance
     * @returns { boolean } true if the provided object is usable by the module
     */
    isValidStance,
    /**
     * @param { ChatacterPF2e } actor
     * @returns { { name: string; uuid: string; img: string; actionUUID: string; effectUUID: string; effectID: string; }[] }
     * the stances available on the actor, effectID is only provided if the effect of the stance is currently present on the actor
     */
    getStances,
    /**
     * will toggle the provided stance effect and remove all other stance effects in the process
     * @param { ChatacterPF2e } actor
     * @param { string } effectUUID
     * @returns { Promise<void> }
     */
    toggleStance,
}
Clone this wiki locally