Options
All
  • Public
  • Public/Protected
  • All
Menu

A module which provides documentation for the various hook events which are dispatched throughout the Foundry Virtual Tabletop client-side software.

Index

Adventure Events

  • preImportAdventure(adventure: Adventure, formData: any, toCreate: any, toUpdate: any): boolean | void
  • A hook event that fires when Adventure data is being prepared for import. Modules may return false from this hook to take over handling of the import workflow.

    Parameters

    • adventure: Adventure

      The Adventure document from which content is being imported

    • formData: any

      Processed data from the importer form

    • toCreate: any

      Adventure data which needs to be created in the World

    • toUpdate: any

      Adventure data which needs to be updated in the World

    Returns boolean | void

    False to prevent the core software from handling the import

  • importAdventure(adventure: Adventure, formData: any, created: any, updated: any): void
  • A hook event that fires after an Adventure has been imported into the World.

    Parameters

    • adventure: Adventure

      The Adventure document from which content is being imported

    • formData: any

      Processed data from the importer form

    • created: any

      Documents which were created in the World

    • updated: any

      Documents which were updated in the World

    Returns void

Application Events

  • renderApplication(application: Application, html: jQuery, data: any): void
  • A hook event that fires whenever an Application is rendered. Substitute the Application name in the hook event to target a specific Application type, for example "renderMyApplication". Each Application class in the inheritance chain will also fire this hook, i.e. "renderApplication" will also fire. The hook provides the pending application HTML which will be added to the DOM. Hooked functions may modify that HTML or attach interactive listeners to it.

    Parameters

    • application: Application

      The Application instance being rendered

    • html: jQuery

      The inner HTML of the document that will be displayed and may be modified

    • data: any

      The object of data used when rendering the application

    Returns void

Canvas Events

  • canvasConfig(config: any): void
  • A hook event that fires immediately prior to PIXI Application construction with the configuration parameters.

    Parameters

    • config: any

      Canvas configuration parameters that will be used to initialize the PIXI.Application

    Returns void

  • canvasInit(canvas: Canvas): void
  • A hook event that fires when the Canvas is initialized.

    Parameters

    • canvas: Canvas

      The Canvas instance being initialized

    Returns void

  • canvasPan(canvas: Canvas, position: { x: number; y: number; scale: number }): void
  • A hook event that fires when the Canvas is panned.

    Parameters

    • canvas: Canvas

      The Canvas instance

    • position: { x: number; y: number; scale: number }

      The applied camera position

      • x: number

        The constrained x-coordinate of the pan

      • y: number

        The constrained y-coordinate of the pan

      • scale: number

        The constrained zoom level of the pan

    Returns void

  • canvasReady(canvas: Canvas): void
  • A hook event that fires when the Canvas is ready.

    Parameters

    • canvas: Canvas

      The Canvas which is now ready for use

    Returns void

  • canvasTearDown(canvas: Canvas): void
  • A hook event that fires when the Canvas is deactivated.

    Parameters

    • canvas: Canvas

      The Canvas instance being deactivated

    Returns void

  • highlightObjects(active: boolean): void
  • A hook event that fires objects are highlighted on the canvas. Callers may use this hook to apply their own modifications or enhancements to highlighted objects.

    Parameters

    • active: boolean

      Is the highlight state now active

    Returns void

CanvasLayer Events

  • A hook event that fires with a CanvasLayer is initially drawn. The dispatched event name replaces "Layer" with the named CanvasLayer subclass, i.e. "drawTokensLayer".

    Parameters

    Returns void

  • A hook event that fires with a CanvasLayer is deconstructed. The dispatched event name replaces "Layer" with the named CanvasLayer subclass, i.e. "tearDownTokensLayer".

    Parameters

    Returns void

CanvasVisibility Events

  • initializeVisionSources(sources: Collection<string, VisionSource>): void
  • A hook event that fires when the set of vision sources are initialized.

    Parameters

    • sources: Collection<string, VisionSource>

      The collection of current vision sources

    Returns void

  • A hook event that fires when the CanvasVisibility layer has been refreshed.

    Parameters

    Returns void

Combat Events

  • combatStart(combat: Combat, updateData: { round: number; turn: number }): void
  • A hook event that fires when a Combat encounter is started.

    Parameters

    • combat: Combat

      The Combat encounter which is starting

    • updateData: { round: number; turn: number }

      An object which contains Combat properties that will be updated. Can be mutated.

      • round: number

        The initial round

      • turn: number

        The initial turn

    Returns void

  • combatTurn(combat: Combat, updateData: { round: number; turn: number }, updateOptions: { advanceTime: number; direction: number }): void
  • A hook event that fires when the turn of the Combat encounter changes.

    Parameters

    • combat: Combat

      The Combat encounter which is advancing or rewinding its turn

    • updateData: { round: number; turn: number }

      An object which contains Combat properties that will be updated. Can be mutated.

      • round: number

        The current round of Combat

      • turn: number

        The new turn number

    • updateOptions: { advanceTime: number; direction: number }

      An object which contains options provided to the update method. Can be mutated.

      • advanceTime: number

        The amount of time in seconds that time is being advanced

      • direction: number

        A signed integer for whether the turn order is advancing or rewinding

    Returns void

  • combatRound(combat: Combat, updateData: { round: number; turn: number }, updateOptions: { advanceTime: number; direction: number }): void
  • A hook event that fires when the round of the Combat encounter changes.

    Parameters

    • combat: Combat

      The Combat encounter which is advancing or rewinding its round

    • updateData: { round: number; turn: number }

      An object which contains Combat properties that will be updated. Can be mutated.

      • round: number

        The new round of Combat

      • turn: number

        The new turn number

    • updateOptions: { advanceTime: number; direction: number }

      An object which contains options provided to the update method. Can be mutated.

      • advanceTime: number

        The amount of time in seconds that time is being advanced

      • direction: number

        A signed integer for whether the turn order is advancing or rewinding

    Returns void

CoreLifecycle Events

  • init(): void
  • A hook event that fires as Foundry is initializing, right before any initialization tasks have begun.

    Returns void

  • i18nInit(): void
  • A hook event that fires once Localization translations have been loaded and are ready for use.

    Returns void

  • setup(): void
  • A hook event that fires when Foundry has finished initializing but before the game state has been set up. Fires before any Documents, UI applications, or the Canvas have been initialized.

    Returns void

  • ready(): void
  • A hook event that fires when the game is fully ready.

    Returns void

Document Events

  • preCreateDocument(document: Document, data: any, options: DocumentModificationContext, userId: string): boolean | void
  • A hook event that fires for every Document type before execution of a creation workflow. Substitute the Document name in the hook event to target a specific Document type, for example "preCreateActor". This hook only fires for the client who is initiating the creation request.

    The hook provides the pending document instance which will be used for the Document creation. Hooked functions may modify the pending document with updateSource, or prevent the workflow entirely by returning false.

    Parameters

    • document: Document

      The pending document which is requested for creation

    • data: any

      The initial data object provided to the document creation request

    • options: DocumentModificationContext

      Additional options which modify the creation request

    • userId: string

      The ID of the requesting user, always game.user.id

    Returns boolean | void

    Explicitly return false to prevent creation of this Document

  • preUpdateDocument(document: Document, changes: any, options: DocumentModificationContext, userId: string): boolean | void
  • A hook event that fires for every Document type before execution of an update workflow. Substitute the Document name in the hook event to target a specific Document type, for example "preUpdateActor". This hook only fires for the client who is initiating the update request.

    The hook provides the differential data which will be used to update the Document. Hooked functions may modify that data or prevent the workflow entirely by explicitly returning false.

    Parameters

    • document: Document

      The Document instance being updated

    • changes: any

      Differential data that will be used to update the document

    • options: DocumentModificationContext

      Additional options which modify the update request

    • userId: string

      The ID of the requesting user, always game.user.id

    Returns boolean | void

    Explicitly return false to prevent update of this Document

  • preDeleteDocument(document: Document, options: DocumentModificationContext, userId: string): boolean | void
  • A hook event that fires for every Document type before execution of a deletion workflow. Substitute the Document name in the hook event to target a specific Document type, for example "preDeleteActor". This hook only fires for the client who is initiating the update request.

    The hook provides the Document instance which is requested for deletion. Hooked functions may prevent the workflow entirely by explicitly returning false.

    Parameters

    • document: Document

      The Document instance being deleted

    • options: DocumentModificationContext

      Additional options which modify the deletion request

    • userId: string

      The ID of the requesting user, always game.user.id

    Returns boolean | void

    Explicitly return false to prevent deletion of this Document

  • createDocument(document: Document, options: DocumentModificationContext, userId: string): void
  • A hook event that fires for every embedded Document type after conclusion of a creation workflow. Substitute the Document name in the hook event to target a specific type, for example "createToken". This hook fires for all connected clients after the creation has been processed.

    Parameters

    • document: Document

      The new Document instance which has been created

    • options: DocumentModificationContext

      Additional options which modified the creation request

    • userId: string

      The ID of the User who triggered the creation workflow

    Returns void

  • updateDocument(document: Document, change: any, options: DocumentModificationContext, userId: string): void
  • A hook event that fires for every Document type after conclusion of an update workflow. Substitute the Document name in the hook event to target a specific Document type, for example "updateActor". This hook fires for all connected clients after the update has been processed.

    Parameters

    • document: Document

      The existing Document which was updated

    • change: any

      Differential data that was used to update the document

    • options: DocumentModificationContext

      Additional options which modified the update request

    • userId: string

      The ID of the User who triggered the update workflow

    Returns void

  • deleteDocument(document: Document, options: DocumentModificationContext, userId: string): void
  • A hook event that fires for every Document type after conclusion of an deletion workflow. Substitute the Document name in the hook event to target a specific Document type, for example "deleteActor". This hook fires for all connected clients after the deletion has been processed.

    Parameters

    • document: Document

      The existing Document which was deleted

    • options: DocumentModificationContext

      Additional options which modified the deletion request

    • userId: string

      The ID of the User who triggered the deletion workflow

    Returns void

EffectsCanvasGroup Events

  • A hook event that fires when the LightingLayer is refreshed.

    Parameters

    Returns void

Game Events

  • pauseGame(paused: boolean): void
  • A hook event that fires when the game is paused or un-paused.

    Parameters

    • paused: boolean

      Is the game now paused (true) or un-paused (false)

    Returns void

GameTime Events

  • updateWorldTime(worldTime: number, delta: number, options: any, userId: string): void
  • A hook event that fires when the World time has been updated.

    Parameters

    • worldTime: number

      The new canonical World time

    • delta: number

      The time delta

    • options: any

      Options passed from the requesting client which triggered the update

    • userId: string

      The ID of the User who changed the world time

    Returns void

InteractionLayer Events

  • A hook event that fires with a InteractionLayer becomes active. The dispatched event name replaces "Layer" with the named InteractionLayer subclass, i.e. "activateTokensLayer".

    Parameters

    Returns void

  • A hook event that fires with a InteractionLayer becomes inactive. The dispatched event name replaces "Layer" with the named InteractionLayer subclass, i.e. "deactivateTokensLayer".

    Parameters

    Returns void

PlaceableObject Events

  • A hook event that fires when a PlaceableObject is initially drawn. The dispatched event name replaces "Object" with the named PlaceableObject subclass, i.e. "drawToken".

    Parameters

    Returns void

  • A hook event that fires when a PlaceableObject is incrementally refreshed. The dispatched event name replaces "Object" with the named PlaceableObject subclass, i.e. "refreshToken".

    Parameters

    Returns void

  • A hook event that fires when a PlaceableObject is destroyed. The dispatched event name replaces "Object" with the named PlaceableObject subclass, i.e. "destroyToken".

    Parameters

    Returns void

ProseMirrorEditor Events

  • createProseMirrorEditor(uuid: string, plugins: any, options: { state: EditorState }): void
  • A hook event that fires whenever a ProseMirror editor is created. The hook provides the ProseMirror instance UUID, a list of plugins, and an object containing the provisional editor state, and a reference to the menu plugin. Hooked functions may append their own plugins or replace the state or menu plugin by replacing their references in the final argument.

    Parameters

    • uuid: string

      A UUID that uniquely identifies this ProseMirror instance.

    • plugins: any

      A list of plugins that will be loaded.

    • options: { state: EditorState }

      The provisional EditorState and ProseMirrorMenuPlugin.

      • state: EditorState

    Returns void

ProseMirrorMenu Events

  • getProseMirrorMenuDropDowns(menu: ProseMirrorMenu, config: { format: ProseMirrorDropDownConfig; fonts: ProseMirrorDropDownConfig }): void
  • A hook even that fires when a ProseMirrorMenu's drop-downs are initialized. The hook provides the ProseMirrorMenu instance and an object of drop-down configuration data. Hooked functions may append their own drop-downs or append entries to existing drop-downs.

    Parameters

    • menu: ProseMirrorMenu

      The ProseMirrorMenu instance.

    • config: { format: ProseMirrorDropDownConfig; fonts: ProseMirrorDropDownConfig }

      The drop-down config.

      • format: ProseMirrorDropDownConfig
      • fonts: ProseMirrorDropDownConfig

    Returns void

  • getProseMirrorMenuItems(menu: ProseMirrorMenu, config: ProseMirrorMenuItem[]): void
  • A hook even that fires when a ProseMirrorMenu's buttons are initialized. The hook provides the ProseMirrorMenu instance and an array of button configuration data. Hooked functions may append their own buttons to the list.

    Parameters

    • menu: ProseMirrorMenu

      The ProseMirrorMenu instance.

    • config: ProseMirrorMenuItem[]

      The button configuration objects.

    Returns void

User Events

  • userConnected(user: User, connected: boolean): void
  • A hook event that fires whenever some other User joins or leaves the game session.

    Parameters

    • user: User

      The User who has connected or disconnected

    • connected: boolean

      Is the user now connected (true) or disconnected (false)

    Returns void