BeneosBattlemaps / Beneos-Multilevel-Tokens

We took over the further development of the MLT module for FoundryVTT in 2024.
MIT License
2 stars 2 forks source link

Multilevel Tokens module for Foundry VTT

Forked from https://github.com/grandseiken/foundryvtt-multilevel-tokens with the author authorization on june 2024.

Beneos is now the official maintener of multilevel-tokens module.

This module for FoundryVTT adds several helpful token automation features, particularly (but not only) suited to maps with multiple levels.

Demonstration

All of the features work using Foundry's built in drawing tools. A new tab in the Drawing Configuration window for any rectangle, ellipse or polygon drawing allows the designated region to be configured with special behaviour:

Configuration menu example

You might also like my other module, Vehicles and Mechanisms.

Installation

You can install this module by searching for it in Foundry's built-in module browser (strongly recommanded), or with the following public URL:

https://raw.githubusercontent.com/BeneosBattlemaps/Beneos-Multilevel-Tokens/main/module.json

Remember to enable the module in the Manage Modules menu after installation.

General use

Creating teleport regions

To create a teleport, you need at least two regions with the same Teleport identifier. The In box should be checked for teleport starting locations, and the Out box for teleport destinations. Any token that moves into an In region will be teleported to an Out region with a matching identifier. If there is more than one such destination region, one will be chosen randomly.

You can check both the In and Out boxes (on two regions with the same identifier) to create a two-way teleport.

Teleport example

Notes

Click-to-activate teleports

By default, teleport regions will automatically teleport any token that moves into the In region. If you check the Activate via map note box on an In region, you can instead use a Map Note as a clickable button to activate the teleport.

To set up a Map Note to use as a teleport activation button, you will need to:

If the GM clicks on the map note, all tokens currently within the region will be teleported. If a player clicks on the map note, any tokens they own within the region will be teleported.

If a player has not enabled display of Map Notes, they will be made temporarily visible when a token the player controls is inside an eligible region, so that the button can be clicked.

Activate via map notes example

Creating token cloning regions

To set up token cloning, you'll need at least two regions with the same Clone identifier. The Source box should be checked for the region where tokens will be cloned from, and the Target box for the region where tokens will be cloned to. Any tokens in the Source region will be automatically cloned to Target regions with a matching identifier.

For example, for the typical case of making tokens on the floor below visible from a balcony above, you could create a Source region covering the part of the lower level that's visible from above, and a Target region in the corresponding "empty space" area of the upper level.

You can check both the Source and Target boxes (on two regions with the same identifier) to clone tokens in both directions.

Cloned tokens behave a little differently from regular tokens. They can't be moved or deleted independently; they don't have a linked actor, aren't controlled by a player, and don't have vision. By default, they have an extra tint color applied to make them easily distinguishable. They inherit most other properties (visibility, size, name, disposition, and so on) from the original token. Any update made to the original token will be synced to its clones.

Token cloning example

True Mirror

The "True Mirror" flag on a cloning region will flip your token images and invert rotation to allow you to add mirrors to scenes. It only does anything if "Mirror horizontally" or "Mirror vertically" are enabled.

Mirror example

Notes

Creating level-based teleports

Level regions provide an alternative way to set up teleports. This method is a little bit less flexible and does not support cross-scene teleporting, but can more convenient to set up in some cases. It works well for large maps with many small paired teleportation points (e.g. staircases or ladders) between adjacent levels of a building.

To use this method, create a region with the Level box checked and an appropriate Level number for each level of your map. Mark each stairway entrance exit on each level with a hidden token named exactly @stairs (you can set up an actor to drag-and-drop for this purpose).

When a token moves onto a @stairs token, it will be teleported to the location of any corresponding @stairs token in the same relative position within a Level region (on the same scene) one level above or below, if one exists. Note that careful placement is necessary here, so it's recommended to make the Level regions exactly the same size and enable snap-to-grid.

Level-based teleports example

Creating macro trigger regions

You can run a specific macro whenever a token enters, leaves, or moves within a particular area, using Macro regions.

Three checkboxes determine which type of events will cause the macro to be triggered:

The Macro name field should be set to the name of the macro to be executed. The macro must have been created by a GM user.

Chat macros will be spoken as if by whichever token entered the region.

Script macros will be executed by the GM whenever one of the chosen events occurs. Within the macro script, the following variables are available:

Note that script macros triggered in this way run on the GM's client, and the GM might not currently be viewing the scene in question. In this case, the Drawing and Token objects mentioned above will be temporary objects created purely for the macro's execution, rather than the currently-visible ones found in canvas.tokens and canvas.drawings.

Enabling and disabling regions

Any automation region can be temporarily disabled by checking the Disable region box in the configuration tab. This can be useful if you want to set automation up in advance, but only enable it when needed.

You can also enable or disable an automation region from e.g. a macro. The flag is stored in data.flags["multilevel-tokens"].disabled. With a Drawing object stored in the variable drawing, the following snippet would toggle the region between enabled and disabled:

drawing.update({flags: {"multilevel-tokens": {disabled: !drawing.data.flags["multilevel-tokens"].disabled}}});

Troubleshooting

Version history