Skip to content

A Foundry VTT module that allows GMs to activate and deactivate tokens for players.

License

Notifications You must be signed in to change notification settings

jagoe/fvtt-module-inactive-tokens

Repository files navigation

Readme

Changelog

A changelog can bout found here.

Description

A Foundry VTT module that allows GMs to activate and deactivate tokens for their players. It produces the same behavior as setting interactive to false, but without disabling the token for the GM.

The main reason I developed this is in order to turn tokens into statues (or statues into sudden enemies!). So I'll also provide the macro that does that here (though you need to install the module Token Magic FX for it to work):

let filterId = 'stone'
let params =
[{
    filterType: "adjustment",
    filterId: filterId,
    saturation: 0,
    // feel free to adjust for a greytone you like (or any color, really)
    red: 0.8,
    green: 0.8,
    blue: 0.8,
}];

let tokens = game.canvas.tokens.controlled
let shouldEnable = !tokens.some(token => TokenMagic.hasFilterId(token, filterId))

if (shouldEnable) {
  tokens.forEach(turnToStone)
} else {
  tokens.forEach(turnToFlesh)
}

function turnToStone(token) {
  TokenMagic.addFilters(token, params)
  InactiveTokensModule.singleton.deactivateTokenForPlayers(token)
}

function turnToFlesh(token) {
  TokenMagic.deleteFilters(token, filterId)
  InactiveTokensModule.singleton.activateTokenForPlayers(token)
}

Installation

Select "Inactive Tokens" in the module installation tool of your choice.
You can also install manually by using the following manifest URL.

Then, as GM, enable the Inactive Tokens module in the Manage Modules settings in the Game Settings tab.

Configuration

The module does not have any configuration.

API

The module provides the following methods than can be called from macros or other modules:

InactiveTokensModule.singleton.activateTokenForPlayers(token: Token | TokenDocument): Promise<void>
InactiveTokensModule.singleton.deactivateTokenForPlayers(token: Token | TokenDocument): Promise<void>
InactiveTokensModule.singleton.isTokenActiveForPlayers(token: Token | TokenDocument): boolean

You'd probably usually want to retrieve a token

  • that has been selected, e.g.: game.canvas.tokens.controlled[0]
  • by id, e.g.: game.canvas.tokens.get(id)
  • from the canvas, e.g.: game.canvas.tokens.documentCollection[id] or game.canvas.tokens.documentCollection.contents[0]

Dependencies

socketlib

This modul requires `socketlib to be installed in order to function.

libWrapper

This module uses the libWrapper library for wrapping core methods. While this is not a hard dependency, it is recommended to install it for the best experience and compatibility with other modules.
You will get another reminder if you load the module without libWrapper being present.

License

This Foundry VTT module is licensed under a GNU General Public License v3.0 License.

About

A Foundry VTT module that allows GMs to activate and deactivate tokens for players.

Resources

License

Stars

Watchers

Forks

Packages

No packages published