module

Template Macro

Endorsements
0
Installs
5.89%
Comments
0
Latest version11.0.1
Minimum Core10
Compatible Core
Last updated6 months ago
Created1 year ago
Authors
Languages English
Systems Dnd5e
Project source Project URL

Template Macro

You can use this module to trigger macros on certain events related to Measured Templates. The events include:

  • when a template is created ("whenCreated"), deleted ("whenDeleted"), moved ("whenMoved"), hidden ("whenHidden"), or revealed ("whenRevealed").
  • when a token enters the area of a template ("whenEntered"), leaves the area ("whenLeaving"), or moves within the area ("whenStaying").
  • when a token moves from outside a template, through it, and ends their movement outside of it ("whenThrough").
  • when a token starts its turn in combat within a template ("whenTurnStart") or ends its turn in combat within a template ("whenTurnEnd").

You can create macros in two ways:

  • place a template and open its config, then click the icon in the header.
  • click the icon in the header of an item that to create the Template Macros on the item (dnd5e only). These macros are then copied to the template when it is created.

Any template macro has four declared helper variables: template (the MeasuredTemplateDocument itself), scene (the parent of the template), token (the token moving, if relevant), and this, which contains a lot of other useful data, most notably any parameters passed through associated hooks.

The module contains some functions found in game.modules.get("templatemacro").api.

  • findContainers(tokenDoc) returns the MeasuredTemplateDocument ids that contain a TokenDocument.
  • findContained(templateDoc) returns the TokenDocument ids that are contained within a MeasuredTemplateDocument.
  • findGrids(A, B, templateDoc) returns the grid cells between the two coordinates that are within a MeasuredTemplateDocument.

Additionally, the MeasuredTemplateDocument now has the function callMacro(type="never", options={}), which executes the appropriate embedded script, if it exists. The types are: "whenCreated", "whenDeleted", "whenMoved", "whenHidden", "whenRevealed", "whenEntered", "whenLeft", "whenThrough", "whenStaying", "whenTurnStart", "whenTurnEnd", "never", the last being a placeholder script meant for manual execution only.

Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x