Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

Using TokenMod to set Vision?

October 08 (2 years ago)

Hello Community,


I've been trying to play with a way to set vision for something such as DND Twilight Cleric's Eyes of Night feature, granting 

Night Vision to a targeted token, ideally through something like a Token Macro my player can click and use  - is this even possible?


I've toyed with the following:

!token-mod {{
  --set 
@{target|token_id}
    has_night_vision#on
    night_vision_distance|300
    night_vision_effect|nocturnal
    defaulttoken
}}

I'm sure there's something I'm missing, but my code understanding is pretty basic, so I can't parse out what's wrong. 
I can select a target with this, but it doesn't set Night Vision on for that token.

Thanks for the help team!

October 08 (2 years ago)
keithcurtis
Forum Champion
Marketplace Creator
API Scripter

Hi Jukite!

If you are intending to use a Token Action, is there a reason you are using @{targeted}? By default, the button would only be available when the intended recipient was selected.

In any case, if targeting is needed, you'll need to tell token-mod that you are intending a targeted token. Just putting the token id in won't be enough. Try this:

!token-mod {{ --ids @{target|token_id} --set has_night_vision#on night_vision_distance|300 night_vision_effect|nocturnal defaulttoken }}



October 09 (2 years ago)

Thanks - that did the trick!


As to the why - The intent was to make it available to that PC/Player specifically - so they can grant Night-vision to whom they select (mainly take work off on my end as DM.) More or less, keeping the player in charge of their abilities. Is it redundant or inelegant?


{ --ids @{target|token_id}

As to this bit , it's clear this is what I was missing! As (hopefully) a learning experience on my end - what's the logic/purpose of this command/line versus what I had (with just the {@target|...}?) 
Is this to tell the API I'm going to call token_id's with the macro?

October 09 (2 years ago)
keithcurtis
Forum Champion
Marketplace Creator
API Scripter

Token mod is set up with attributes and values. It can set a value, but it needs to know what to do with that number. Putting --ids in front of the token id lets the script know that the intent of that token id is to provide a target. There are lots of other things you can do with a token id.

BTW, if you intend players to use this, make sure you set the toggle on token mod players_can_ids. I forget the exact wording, but it's in the help doc that token mod installs in your game. Make sure you trust your group if you do that. Much mischief can ensue from allowing players that kind of power.

October 09 (2 years ago)

LOL Thanks Keith, I appreciate the advice. Most of my players are unfamiliar or uninterested in the nuts & bolts of APIs or learning/using their commands, so I'm not too worried, but I'll understand & appreciate the advice, and will consider how I implement player accessible macros and such!


Thanks for the explanation as well.

October 09 (2 years ago)
keithcurtis
Forum Champion
Marketplace Creator
API Scripter

I hear you. My players are all very experienced at the game, but when it comes to doing tasks on the VTT, it's often like the "which die do i roll here?" phenomenon.

October 09 (2 years ago)

LOL right? At least a lot of scripts you awesome guys put out helps the GMing side more than anything else. I really can't thank you guys enough for the work a lot of you do to make cool things/tricks for running a lot for different games. Thank you!