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

[Script Update] TokenMod -- An interface to adjusting properties of a token from a macro or the chat area.

August 05 (3 years ago)
The Aaron
Roll20 Production Team
API Scripter

This is an existing bug with the UDL implementation for the API and something that Roll20 will need to fix.

August 05 (3 years ago)

Okay, at least it's not me : )
Are there any known workarounds?

Thanks for the quick reply

August 05 (3 years ago)
The Aaron
Roll20 Production Team
API Scripter

Not really. =(

Please help. My game was looking good but when I toggled on player can id my whole game got messed up. My chat went blank, and even blinks on and off and my buttons in the top left ie. pointer, layer, fx and initiative buttons completely disappear when I hover over them. My whole screen in just kind of wonky. I tried to delete tokenmod and reinstall it but nothing has changed. And it all started when I toggled the player can id's button. Any help would be awesome. 

Actually i kind of figured it out. Not really but I fixed it :). I had to delete TokenMod then completely clear my chat archive and that worked. For some reason every time I re entered my game there was some script from tokenmod in the chat that was messing up my screen. So when I cleared my chat archive it fixed it. Weird I know.


August 11 (3 years ago)
keithcurtis
Forum Champion
Marketplace Creator
API Scripter

It's almost certainly a coincidence. That setting toggles a javascript variable and would have nothing to do with browser behavior such as you describe. If restarting the computer (not just the browser) doesn't clear it up, try running in a private browsing window to eliminate most instances of an interfering extension. Probably not a bad idea to delete the cache as well. If you want to be thorough, you could also try clearing the Chat Archive. A game's Creator is often able to fix issues with their Text Chat by clearing the Chat Archive (note: not clearing your current Chat Log). A GM might want to copy/back up the Chat Archive before the Creator clears it.

August 11 (3 years ago)
The Aaron
Roll20 Production Team
API Scripter

I think this might be a bug in the latest Chrome.  I had a weird issue with character replacements and flashing text a few days ago, but it cleared up on refresh, or possibly restart of the browser.

August 14 (3 years ago)


keithcurtis said:

It's almost certainly a coincidence. That setting toggles a javascript variable and would have nothing to do with browser behavior such as you describe. If restarting the computer (not just the browser) doesn't clear it up, try running in a private browsing window to eliminate most instances of an interfering extension. Probably not a bad idea to delete the cache as well. If you want to be thorough, you could also try clearing the Chat Archive. A game's Creator is often able to fix issues with their Text Chat by clearing the Chat Archive (note: not clearing your current Chat Log). A GM might want to copy/back up the Chat Archive before the Creator clears it.

I think he should try another browser, that's seems the simplest. Try Friefox if you're using Chrome or vice versa. Or, if nothing helps, IE (yikes). That could rule out a browser problem.

August 16 (3 years ago)

Edited August 16 (3 years ago)
Nini
Pro

i! I got a question.

Is it possible to change this value of a token?

https://prnt.sc/1pynjfc


I ask because I've been trying to figure it out but so far the attributes provided in the guidelines don't seem to work.

You may think that using --set rotation| would do the trick, BUT I also use the TokenLock script, which won't let my players use that macro, so I kind of need to change that particular token setting, but I've no idea if it's possible. Can someone help? :(


Is tokenmod able to set the Tint Color attribute for night vision? I've been trying to figure it out but just can't seem to find the answer. Any help would be much appreciated and I love the work you guys do!

August 17 (3 years ago)
The Aaron
Roll20 Production Team
API Scripter


Ninix said:

i! I got a question.

Is it possible to change this value of a token?

https://prnt.sc/1pynjfc


I ask because I've been trying to figure it out but so far the attributes provided in the guidelines don't seem to work.

You may think that using --set rotation| would do the trick, BUT I also use the TokenLock script, which won't let my players use that macro, so I kind of need to change that particular token setting, but I've no idea if it's possible. Can someone help? :(


That's directional_bright_light_center or directional_low_light_center.  Be sure that has_directional_bright_light is on, or has_directional_low_light.

August 17 (3 years ago)
The Aaron
Roll20 Production Team
API Scripter


Farzivel said:


Is tokenmod able to set the Tint Color attribute for night vision? I've been trying to figure it out but just can't seem to find the answer. Any help would be much appreciated and I love the work you guys do!


Yes, that's night_vision_tint

August 22 (3 years ago)
JP
Plus

I'm having trouble converting this legacy dynamic lighting token-mod command to work with the new dynamic lighting features / command. The token mod effect is to simulate a flashlight, by illuminate the area in front of the token in short (15-degree) arc.

Here's the command that used to work with legacy dynamic lighting:
!token-mod --set light_hassight|yes light_otherplayers|yes  light_angle|30 light_radius|15 light_dimradius|10 

That used to work with the old dynamic lighting, and I'm prepping my first map to use the new dynamic lighting feature. I tried this:

!token-mod --set bright_vision|yes has_directional_bright_light|yes directional_bright_light_center|0 light_angle|15 directional_bright_light_total|10 light_otherplayers|yes

No light emits from the token ... what am I missing?

August 23 (3 years ago)
The Aaron
Roll20 Production Team
API Scripter

If you open the token after running the command send them save it, does that fix the vision?  This sounds like an existing Roll20 bug. 

HI all,


Is the players journal a parameter than can be adapted by token mod ?


For example, if i want to give a player control over conjured animals, i can set him to control the tokens, but he cannot access the sheet if not in his journal.

Don't know if that's a possibility with token mod.


thanks for your answer !

August 29 (3 years ago)

Edited August 29 (3 years ago)
JP
Plus


The Aaron said:

If you open the token after running the command send them save it, does that fix the vision?  This sounds like an existing Roll20 bug. 


I flipped through some back threads, and figured out this was what I needed:

!token-mod {{

  --on

    emits_bright

    emits_low

    has_directional_bright_light

  --set

    bright_distance#10

    low_distance#6

    directional_bright_light_total#20

}}

August 29 (3 years ago)
The Aaron
Roll20 Production Team
API Scripter

Ah!  Glad you got it worked out!

September 05 (3 years ago)


Marco W. said:

Okay, at least it's not me : )
Are there any known workarounds?

Thanks for the quick reply


So is this the same issue as switching from a candle's light to a torch's and the actual light not changing?



September 05 (3 years ago)
The Aaron
Roll20 Production Team
API Scripter

Very likely. If you run the command and it doesn't seem to change everything, then you open the token properties and just click save and everything is fixed, that's the Roll20 bug. 

September 05 (3 years ago)

Edited September 05 (3 years ago)

I've looked around a bit, and gave the handout doc a read, but there's no handy way to place multiple tokens in a nice ordered grid is there?


Big fan, I've used TokenMod for several campaigns now  (edit: apparently Roll20 doesn't recognise the unicode thumbsup emoji...)

IS it possible to set a bar value by reference to another bar value

eg --set bar1_value|bar2_max

September 06 (3 years ago)
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
!token-mod --set bar1_value|@(selected|bar2_max}

...should do it. This assumes the token is selected. You might need to use different identification syntax depending on the need. Note that this will only work correctly on one token at a time. To iterate across a selected group of tokens would reuire a couple of Timmaugh's meaa scripts.

That eg doesnt work, it puts the text into the field rather than the value... there must be something else required to translate the value. I've tried the common ones but not found an answer yet.

September 06 (3 years ago)
The Aaron
Roll20 Production Team
API Scripter

Tubal said:

I've looked around a bit, and gave the handout doc a read, but there's no handy way to place multiple tokens in a nice ordered grid is there?

Not with TokenMod, but here's a little script I wrote to do that called MarshalTokens.  Just select the tokens and run:

!marshal-tokens

and it will put them in as close to a square as it can.

Code:

on('ready',()=>{

  const positioner = (x,y) => {
    const shell = (n) => Math.ceil(Math.sqrt(n));
    const xyForN = (n) => {
      let s = shell(n);
      let sm = s-1;
      let sSeq=n-(Math.pow(sm,2));
      let pSeq=Math.ceil(sSeq/2);
      return {
        x: (sSeq%2 ? pSeq : s)-1,
        y: (sSeq%2 ? s : pSeq)-1
      };
    };
    let startx = x;
    let starty = y;
    let count=0;

    return (obj)=>{
      let coord = xyForN(++count);
      obj.set({
        top: starty+(coord.y*70),
        left: startx+(coord.x*70)
      });
    };
  };

  const normalizer = (n) => {
    return (Math.max(0,Math.floor((n-35)/70))*70)+35;
  };

  on('chat:message',function(msg){
    if('api'===msg.type && /^!marshal-tokens(\b\s|$)/i.test(msg.content) && playerIsGM(msg.playerid)){

      let tokens = [...new Set([
        ...msg.content.split(/\s+/).slice(1),
        ...((msg.selected && msg.selected.map(s=>s._id)) || [])
      ])]
        .map(id=>getObj('graphic',id))
        .filter(g=>undefined !== g)
        ;
      let firstToken = (tokens[0]||{get:()=>0});
      let x=normalizer(firstToken.get('left'));
      let y=normalizer(firstToken.get('top'));
      let poser = positioner(x,y);

      tokens.forEach(poser);
    }
  });
});


September 06 (3 years ago)
The Aaron
Roll20 Production Team
API Scripter

Kevin Flynn said:

That eg doesnt work, it puts the text into the field rather than the value... there must be something else required to translate the value. I've tried the common ones but not found an answer yet.

Can you post what command you're running, and a picture of what is in the bars for the token in question?


September 06 (3 years ago)
keithcurtis
Forum Champion
Marketplace Creator
API Scripter

Hmm. My fault, probably. I might have been sloppy there.It should have been:

!token-mod --set bar1_value|@{selected|bar2|max}

...Lookups use a different syntax.


If it's a text value, you probably want

!token-mod --set bar1_value|"@{selected|bar2|max}"
...to account for spaces/
September 06 (3 years ago)
The Aaron
Roll20 Production Team
API Scripter

If your just trying to set the bar back to its max value, there's a pseudo property for that.  I'm pretty sure this is it, but search the docs for reset to be sure:

!token-mod --set bar3_reset|


That fixed it, now I see it the bell rings...thks.

September 06 (3 years ago)
keithcurtis
Forum Champion
Marketplace Creator
API Scripter

Ah, the example showed two different bars. Different macro needed.

September 07 (3 years ago)

Edited September 07 (3 years ago)

The Aaron said:

Not with TokenMod, but here's a little script I wrote to do that called MarshalTokens.  Just select the tokens and run:

Close enough, thanks!

I use these scripts to handle my NPC portraits. I have a bunch of buttons to set sizes and layers etc to reveal and hide them.

September 19 (3 years ago)

If someone has a functional bullseye lantern syntax for UDL Tokenmod I would love to see it as I have gone crosseyed for hours trying to figure out why its not working.  I feel like there is a bug here cause when it tries to work it breaks all light till you manually go in and fiddle with the save button.  

September 19 (3 years ago)
The Aaron
Roll20 Production Team
API Scripter

There very definitely is a bug. That's on the Roll20 side. API changes to UDL don't trigger an update on the token's light settings. For now, you have to open the edit properties and save to force an update. 

September 19 (3 years ago)

Is it still the same bug that blocks the update of the views on the observer script? 

September 19 (3 years ago)
The Aaron
Roll20 Production Team
API Scripter

Yes, same bug. 

September 20 (3 years ago)

Everything seems to work except for the directional light button that toggles it on and off to me but maybe I'm just incorrectly relying upon ctrl+L too much and haven't actually put this session to use with actual live players yet to see it fail to work.  Everything but the bullseye lantern works.  

September 20 (3 years ago)
keithcurtis
Forum Champion
Marketplace Creator
API Scripter


DM Eddie said:

Everything seems to work except for the directional light button that toggles it on and off to me but maybe I'm just incorrectly relying upon ctrl+L too much and haven't actually put this session to use with actual live players yet to see it fail to work.  Everything but the bullseye lantern works.  

Yup, I can verify that's the same bug. Fortunately, I don't think I have ever had a player want to use a bullseye lantern.


September 23 (3 years ago)


DM Eddie said:

If someone has a functional bullseye lantern syntax for UDL Tokenmod I would love to see it as I have gone crosseyed for hours trying to figure out why its not working.  I feel like there is a bug here cause when it tries to work it breaks all light till you manually go in and fiddle with the save button.  


This is the macro I use. 
!token-mod --on emits_bright_light has_directional_bright_light --off emits_low_light --set bright_light_distance#120 low_light_distance#60 directional_bright_light_center#90 directional_bright_light_total#10


It seems to work for me. 



September 24 (3 years ago)

Edited September 24 (3 years ago)

hi Aaron,

Thanks for this awesome script. I use it all the time :)

Maybe its a stupid question, but why is there these parameters in the setting of directional light

directional_bright_light_center
directional_low_light_center









directional_bright_light_total
directional_low_light_total









on the edit properties page they seem not to destinguish between the two. 















September 24 (3 years ago)

Edited September 24 (3 years ago)

This has been my most dedicated effort to use dynamic lighting for a group I host for and I set up the macro for token mod perfectly fine a few days ago, it worked fully.  After this weeks patch, whenever I use the light macro it changes the entire area where the lighting would be to complete darkness.  I have done NOTHING to my game session since I made the functional keys.  Please tell me this is happening to everyone or I'm going to be stuck reverting for the thousandth time back to LDL.  

?{What Lightsource?|Turn off lights,!token-mod --off emits_bright emits_low|Candle,!token-mod --on has_bright_light_vision emits_bright emits_low --set bright_distance#5 low_distance#5|Moon Touched Weapon,!token-mod --on has_bright_light_vision emits_bright emits_low --set bright_distance#15 low_distance#15|Torch or Light Cantrip,!token-mod --on has_bright_light_vision emits_bright emits_low --set bright_distance#20 low_distance#20|Lamp,!token-mod --on has_bright_light_vision emits_bright emits_low --set bright_distance#15 low_distance#30|Hooded Lantern,!token-mod --on has_bright_light_vision emits_bright emits_low --set bright_distance#30 low_distance#30}

September 24 (3 years ago)
Joe
Pro

Hi Aaron, I'm trying to set up a macro that will allow the players to link a token to their character sheet. But for some reason the following line is giving me an error:

!token-mod --set represents|@{"?{Character}"|character_id}

The error message is:

TypeError: u is undefined

Do you know what might be going on?  I know I have to expand the macro to also link bars and things eventually, but I was starting with getting this command working.  Thanks for your time!

September 24 (3 years ago)
The Aaron
Roll20 Production Team
API Scripter

Probably you want either:

!token-mod --set represents|"?{Character}"

Or

!token-mod --set represents|@{?{Character}|character_id}

In the former case, token mod will search for the character by name (or name fragment), in the latter the player types the name precisely and Roll20 does the expansion to the character id in the local client before passing it to the API.  I've not tried this second case and I don't know if Roll Queries can be used for attribute expansion like that, I'd have to check.


September 24 (3 years ago)
timmaugh
Pro
API Scripter

Pretty sure that second formation won't work, but it will work if you put the sheet call into a Fetch construction:

!token-mod --set represents|@(?{Character}|character_id)

That will give the roll query time to resolve before Fetch goes to find the character.

September 24 (3 years ago)
Joe
Pro


The Aaron said:

Probably you want either:

!token-mod --set represents|"?{Character}"

Or

!token-mod --set represents|@{?{Character}|character_id}

In the former case, token mod will search for the character by name (or name fragment), in the latter the player types the name precisely and Roll20 does the expansion to the character id in the local client before passing it to the API.  I've not tried this second case and I don't know if Roll Queries can be used for attribute expansion like that, I'd have to check.


The first suggestion seems like the better option for what I want, so it being simpler is a bonus.  I’ll let you know if there are any issues when I get a chance to try it, but thanks regardless! :-)


September 25 (3 years ago)
Joe
Pro

For the record, your first suggestion worked great, thanks again!

Here is my final macro, though at the moment I have to run it twice because the first time I run it on a blank token (created from a rollable table in this case) I get "No character was found for 'selected'" in the chat, and the token name is set to ""selected" (including the leading quotation mark).  But running the macro again immediately then fixes it.

!token-mod --on showname showplayers_name showplayers_bar3 --set represents|"?{Character}" name|"@{selected|character_name}" bar1_link|hp bar2_link|ac bar3_link|hp_temp defaulttoken

I think I understand why it is doing that.  If you have any suggestion for how to have it work for the token name on the first run, I'm curious to hear it, but this is an easy enough workaround that I'm fine with it. :-)

September 26 (3 years ago)

Edited September 26 (3 years ago)
Joe
Pro

I'm looking at the TokenMod help journal entry, and it includes the following:

When appending a url, you can use a  followed by a number to specify where to place the new image.  Indicies start at 1.

I think that you meant to say "@ followed by a number".


The reason I'm looking is because my players have requested a way to get a token automatically from a PC's avatar.  As players they can set the avatar, and the above TokenMod macro I made lets them link an existing token to a PC, but they can't drop any new images onto the tabletop even if they go make one from their avatar image using https://rolladvantage.com/tokenstamp/ or some other tool.

I was thinking if they could create any token (I guess you can always drag a die roll from chat onto the tabletop, right?), they could use TokenMod to change the image using something like the following:

!token-mod --set imgsrc|URL

Where URL is the address of an image in their image library.  But does that work for players, who don't normally have access to their image library in the game?  I'd test that myself, but that leads me to my second question: where do you get that URL?  Even if they create their own game to have access to the images tab of the journal area, I'm having trouble getting the URL of any of those images.


Thanks for all your help!  I'd be great if my players could get their own token images set up rather than sending them to me and me having to do it.  ;-)

Automating this whole token process could also be considered a feature request for your PlayerCharacters script, if you think it makes sense.  Creating a default token with a player-chosen image is probably something any player that creates their own new PC will want to do.  Maybe copying it from the current avatar would be a way to use the existing interface?

September 26 (3 years ago)
The Aaron
Roll20 Production Team
API Scripter

I'll check when I get a chance, probably the @ is getting eaten by the chat. Did you check the handout?

The easiest way to get the image url is to select a token on the tabletop and press Z, then right click and copy the image path. 

September 26 (3 years ago)
Joe
Pro

I meant to say that I was looking at the handout.  And thanks, I'll use that method for getting the URL!