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.

1628187806
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.
Okay, at least it's not me : ) Are there any known workarounds? Thanks for the quick reply
1628200128
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.
1628699820
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.
1628700665
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.
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.
1629157192

Edited 1629157282
Nini
Plus
i! I got a question. Is it possible to change this value of a token? <a href="https://prnt.sc/1pynjfc" rel="nofollow">https://prnt.sc/1pynjfc</a> I&nbsp;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&nbsp; --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!
1629218794
The Aaron
Roll20 Production Team
API Scripter
Ninix said: i! I got a question. Is it possible to change this value of a token? <a href="https://prnt.sc/1pynjfc" rel="nofollow">https://prnt.sc/1pynjfc</a> I&nbsp;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&nbsp; --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.&nbsp; Be sure that has_directional_bright_light is on, or has_directional_low_light.
1629218824
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
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&nbsp; light_angle|30 light_radius|15 light_dimradius|10&nbsp; 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?
1629692457
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? &nbsp;This sounds like an existing Roll20 bug.&nbsp;
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 !
1630198123

Edited 1630201862
JP
Plus
The Aaron said: If you open the token after running the command send them save it, does that fix the vision? &nbsp;This sounds like an existing Roll20 bug.&nbsp; I flipped through some back threads, and figured out this was what I needed: !token-mod {{ &nbsp; --on &nbsp;&nbsp;&nbsp; emits_bright &nbsp;&nbsp;&nbsp; emits_low &nbsp;&nbsp;&nbsp; has_directional_bright_light &nbsp; --set &nbsp;&nbsp;&nbsp; bright_distance#10 &nbsp;&nbsp;&nbsp; low_distance#6 &nbsp;&nbsp;&nbsp; directional_bright_light_total#20 }}
1630242805
The Aaron
Roll20 Production Team
API Scripter
Ah! &nbsp;Glad you got it worked out!
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?
1630849846
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.&nbsp;
1630874921

Edited 1630875001
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&nbsp; (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
1630897465
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.
1630898977
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.&nbsp; 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',()=&gt;{ const positioner = (x,y) =&gt; { const shell = (n) =&gt; Math.ceil(Math.sqrt(n)); const xyForN = (n) =&gt; { 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)=&gt;{ let coord = xyForN(++count); obj.set({ top: starty+(coord.y*70), left: startx+(coord.x*70) }); }; }; const normalizer = (n) =&gt; { return (Math.max(0,Math.floor((n-35)/70))*70)+35; }; on('chat:message',function(msg){ if('api'===msg.type &amp;&amp; /^!marshal-tokens(\b\s|$)/i.test(msg.content) &amp;&amp; playerIsGM(msg.playerid)){ let tokens = [...new Set([ ...msg.content.split(/\s+/).slice(1), ...((msg.selected &amp;&amp; msg.selected.map(s=&gt;s._id)) || []) ])] .map(id=&gt;getObj('graphic',id)) .filter(g=&gt;undefined !== g) ; let firstToken = (tokens[0]||{get:()=&gt;0}); let x=normalizer(firstToken.get('left')); let y=normalizer(firstToken.get('top')); let poser = positioner(x,y); tokens.forEach(poser); } }); });
1630899153
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?
1630905870
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/
1630907794
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. &nbsp;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.
1630908862
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Ah, the example showed two different bars. Different macro needed.
1631052162

Edited 1631052218
The Aaron said: Not with TokenMod, but here's a little script I wrote to do that called MarshalTokens.&nbsp; 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.
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.&nbsp; 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.&nbsp;&nbsp;
1632063800
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.&nbsp;
Is it still the same bug that blocks the update of the views on the observer script?&nbsp;
1632064086
The Aaron
Roll20 Production Team
API Scripter
Yes, same bug.&nbsp;
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.&nbsp; Everything but the bullseye lantern works.&nbsp;&nbsp;
1632112434
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.&nbsp; Everything but the bullseye lantern works.&nbsp;&nbsp; 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.
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.&nbsp; 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.&nbsp;&nbsp; This is the macro I use.&nbsp; !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.&nbsp;
1632471315

Edited 1632471441
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&nbsp; the edit properties page they seem not to destinguish between the two.&nbsp;
1632474864

Edited 1632474889
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.&nbsp; After this weeks patch, whenever I use the light macro it changes the entire area where the lighting would be to complete darkness.&nbsp; I have done NOTHING to my game session since I made the functional keys.&nbsp; Please tell me this is happening to everyone or I'm going to be stuck reverting for the thousandth time back to LDL.&nbsp;&nbsp; ?{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}
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?&nbsp; I know I have to expand the macro to also link bars and things eventually, but I was starting with getting this command working.&nbsp; Thanks for your time!
1632487771
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. &nbsp;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.
1632489916
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.
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. &nbsp;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. &nbsp;I’ll let you know if there are any issues when I get a chance to try it, but thanks regardless! :-)
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).&nbsp; 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.&nbsp; 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. :-)
1632615742

Edited 1632615802
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.&nbsp; 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 <a href="https://rolladvantage.com/tokenstamp/" rel="nofollow">https://rolladvantage.com/tokenstamp/</a> 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.&nbsp; But does that work for players, who don't normally have access to their image library in the game?&nbsp; I'd test that myself, but that leads me to my second question: where do you get that URL?&nbsp; 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!&nbsp; 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.&nbsp; ;-) Automating this whole token process could also be considered a feature request for your PlayerCharacters script, if you think it makes sense.&nbsp; Creating a default token with a player-chosen image is probably something any player that creates their own new PC will want to do.&nbsp; Maybe copying it from the current avatar would be a way to use the existing interface?
1632616046
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.&nbsp;
I meant to say that I was looking at the handout.&nbsp; And thanks, I'll use that method for getting the URL!