Saibot393 / perceptive

A small Foundry VTT module to handle a few vision based enhancements
MIT License
9 stars 5 forks source link

Vision Channel Macro #105

Open shalemppl opened 2 months ago

shalemppl commented 2 months ago

Sorry if this is a silly question, but it's my first attempt at scripting a macro in Foundry. Anyway, I'd like a very simple Macro that will change whether a character can see a certain token. I created a Vision Channel and everything is working when I manually click the Receives checkbox on and off for the caracter. However, when I try to do it through a macro, it's not working. Here's what I got:

token.actor.update({"flags.perceptive.VisionChannelsFlag.iLFT3vA9WHZzs8bX.Receives" : false});

(I copied the VCID from the Vision Channels window, so that should not be the problem. Any help would be appreciated. (FYI, using Foundry v12).

Saibot393 commented 2 months ago

The code should work. However, notice that the "Receive" setting does not synch between tokens and actor, rather actor override tokens, so the token specific menu will not display if the actor has the flag set. This is because the actor flags are mainly intended to be used with active effects.

Also, if you are interested in a few (vision channels specific) macros, there is a folder with example macros in the perceptive compendium (Examples>Vision Channels). I have added a few QoL api functions here, for example if you do not want to manually look up the id of VC, you can simply use game.modules.get("perceptive").api.VisionChannelsUtils.VCIDsfromNames(vChannelNames) where vChannelNames is an array with, well, channel names. The function returns an array with the channel IDs (same order).