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.

1549487102
vÍnce
Pro
Sheet Author
Aaron has issues... ;-P
1549493502
The Aaron
Roll20 Production Team
API Scripter
Hahaha!  Weighted dice actually builds Rollable Tables for dice that have a minimum, such as an 8 sided die with 5 faces for 5, 6,7, and 8. Kind of like [[1d8r<5]], but with the right probabilities.  But to answer your question, it would look like it is now, with multiple copies of the status marker, each with a digit. The difference would be that it’s interfsce would deal with the number as a single instance, rather than one instance per digit.  blue:32 Instead of  blue[1]:3|blue[2]:2
The Aaron said: Hahaha!  Weighted dice actually builds Rollable Tables for dice that have a minimum, such as an 8 sided die with 5 faces for 5, 6,7, and 8. Kind of like [[1d8r<5]], but with the right probabilities.  But to answer your question, it would look like it is now, with multiple copies of the status marker, each with a digit. The difference would be that it’s interfsce would deal with the number as a single instance, rather than one instance per digit.  blue:32 Instead of  blue[1]:3|blue[2]:2 well, I guess that's something.  But I suppose RealizeStatusMarkers would play hell with something like that.  Also, visually, it's still divided, and with them packing things closer and closer, more than 3 status markers and that will become difficult to read.  Granted, they did well in reducing size to manageable.  But when u need to see the numbers on them, they limit the user being able to see those numbers.  Wish we could get multiple digits on one number instead, but we're limited to the Roll20 backbone in that regard, probably.
1549499184
The Aaron
Roll20 Production Team
API Scripter
yup
Any updates on the elevation code?  Or on the changes to Roll20 Dynamic Lighting/ how it effects TokenMod?
1550764028
The Aaron
Roll20 Production Team
API Scripter
The elevation code is on my short list, but I’ve been on travel and swamped with work, so haven’t made progress.  I dont know about Dynanic Lighting changes that would have an effect on TokenMod, can you elucidate?
I think peeps were talking about something with auras?
1550903753
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Wolf Thunderspirit said: I think peeps were talking about something with auras? The aura issue on the previous page appears to be a Roll20 bug.
1551664585
The Aaron
Roll20 Production Team
API Scripter
Yup: Update v0.8.9  -- Added the argument  --ignore-selected  which allows writing macros that won't change any tokens that happen to be selected. !token-mod --ignore-selected --set statusmarkers|red:3 --ids -Jny0PfbtztLnCQv4M5y This is most useful when you are using hidden tokens as a backing store for state information (time, rounds, money, etc). (Thanks OldSchoolChris!) This usually isn't a problem as @{target|token_id} has a bug where it forces selected IDs not to be sent to the API.  Are you specifying the ID directly as above, or did that bug get fixed?
Hey, there's this macro I used for a while that broke a long time ago. I'm not going to pretend I know anything about the code, but could you tell me what's wrong with it? !token-mod {{   --off showname showplayers_bar3   --on showplayers_name   --set bar1_value|@{selected|npc_ac} bar3_value|@{selected|hp|max} bar3_max|@{selected|hp|max} bar3_link|   --set layers|objects }}
1551853449
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Not sure what's the part that's not working, but that last line should be:   --set layer|objects Singular, instead of plural.
1551873352
The Aaron
Roll20 Production Team
API Scripter
What Keith said. 
1552117623
The Aaron
Roll20 Production Team
API Scripter
That's a bug that was introduced with the latest big update from Roll20.  I've not had the chance to track down a repeatable case yet, but if you have steps to cause it to happen 100% of the time, that would be super helpful.
1552157806
The Aaron
Roll20 Production Team
API Scripter
That’s awesome!  Thanks for tracking that down, I’ll build a minimum reproduction script and give it to the devs. Hopefully they can use it to fix the issue. 
Anyone else having issue with tokenmod not adding negative numbers in the lightdim with the dropdown list for light?
1552167430
The Aaron
Roll20 Production Team
API Scripter
Can you give an example of the command you’re running that isn’t working?
!token-mod --set ?{Vision|Torch, light_radius#40 light_dimradius#20 light_hassight#yes light_angle#360 light_otherplayers#yes|Light Cantrip, light_radius#40 light_dimradius#20 light_hassight#yes light_angle#360 light_otherplayers#yes|Hooded Lantern, light_radius#60 light_dimradius#30 light_hassight#yes light_angle#360 light_otherplayers#yes|Bullseye Lantern, light_radius#120 light_dimradius#60 light_angle#60 light_hassight#yes light_otherplayers#yes|Lamp, light_radius#30 light_dimradius#15 light_hassight#yes light_angle#360 light_otherplayers#yes|Candle, light_radius#5 light_dimradius#=0 light_hassight#yes light_angle#360 light_otherplayers#yes|Darkvision, light_radius#60 light_dimradius#=-5 light_hassight#yes light_angle#360 light_otherplayers#no|Darkvision (90'), light_radius#90 light_dimradius#=-5 light_hassight#yes light_angle#360 light_otherplayers#no|Darkvision (120'), light_radius#120 light_dimradius#=-5 light_hassight#yes light_angle#360 light_otherplayers#no|Warlock Devil's Sight, light_radius#120 light_dimradius#=120 light_hassight#yes light_angle#360 light_otherplayers#no|No light source(Dusk), light_radius#120 light_dimradius#=-5 light_hassight#yes light_angle#360 light_otherplayers#no|Fog, light_radius#200 light_dimradius#=5 light_hassight#yes light_angle#360 light_otherplayers#no|No light source, light_radius#10 light_dimradius#=-5 light_hassight#yes light_angle#360 light_otherplayers#no|Blinded, light_hassight#no light_angle#360 light_otherplayers#no|Flametongue Weapon, light_radius#40 light_dimradius#40 light_hassight#yes light_angle#360 light_otherplayers#yes|Sun Blade, light_radius#30 light_dimradius#30 light_hassight#yes light_angle#360 light_otherplayers#yes}
1553014873
The Aaron
Roll20 Production Team
API Scripter
Ok, sorry for the delay.&nbsp; I've tracked down this issue and fixed it in the latest pull request:&nbsp;&nbsp;<a href="https://github.com/shdwjk/Roll20API/blob/master/TokenMod/TokenMod.js" rel="nofollow">https://github.com/shdwjk/Roll20API/blob/master/TokenMod/TokenMod.js</a>
1553014989
The Aaron
Roll20 Production Team
API Scripter
Update v0.8.44 &nbsp;-- Fixed bug with setting negative numbers as values. (Thanks&nbsp; Kilter )
1553735844
The Aaron
Roll20 Production Team
API Scripter
This update is now live.
Thanks Aaron, looks to be working.
1553772733
The Aaron
Roll20 Production Team
API Scripter
No problem! Thanks for pointing me toward it.&nbsp;
Hi i have a question.&nbsp; I've been trying to figure out how to&nbsp; "!token-mod --order back" to a token without having to select the token. Like putting in a macro and having it just happen with the command without having to highlight it.&nbsp; Is this able to be done?&nbsp; and if so how? I'm very much stumped.&nbsp;
1553814343
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Look up the --ids option. Best place to check documentation is with !token-mod --help. Not all the other sources are as up to date. ids causes it to affect a token or tokens by id number. I have a number of traps (images) that can be revealed on any given map by a central "control panel" macro using this technique.
1553814453
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
From the help: Token Specification By default, any selected token is adjusted when the command is executed. Note that there is a bug where using @{target|} commands, they may cause them to get skipped. --ids &nbsp;takes token ids to operate on, separated by spaces. !token-mod --ids -Jbz-mlHr1UXlfWnGaLh -JbjeTZycgyo0JqtFj-r -JbjYq5lqfXyPE89CJVs --on showname showplayers_name Usually, you will want to specify these with the @{target|} syntax: !token-mod --ids @{target|1|token_id} @{target|2|token_id} @{target|3|token_id} --on showname showplayers_name --ignore-selected &nbsp;can be used when you want to be sure selected tokens are not affected. This is particularly useful when specifying the id of a known token, such as moving a graphic from the gm layer to the objects layer, or coloring an object on the map.
I've been using the --ids option and trying to figure it out. But Keep getting&nbsp; TypeError: Cannot read property 'substring' of undefined&nbsp; How do i figure out the token's id number?&nbsp; !token-mod --ignore-selected --ids @{crow} --flip fliph Is what i used. But doesn't seem to effect the token I have out on the field by the token's image name. I've tried switching it around to a char sheet with no better luck. Thus why i'm stumped.&nbsp; Do i have to designate a token ID by some other means?&nbsp;
1553817003

Edited 1553817068
The Aaron
Roll20 Production Team
API Scripter
--ids must always be the last part of the command.&nbsp; Also, you need to specify a token_id or character_id. Try one of: !token-mod --ignore-selected --flip fliph --ids @{crow|character_id} !token-mod --ignore-selected --flip fliph --ids @{selected|token_id} !token-mod --ignore-selected --flip fliph --ids @{target|token_id}
1553818595
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
The Aaron said: --ids must always be the last part of the command.&nbsp; Does that mean that the help example is incorrect? !token-mod --ids -Jbz-mlHr1UXlfWnGaLh -JbjeTZycgyo0JqtFj-r -JbjYq5lqfXyPE89CJVs --on showname showplayers_name
1553819259

Edited 1553821113
No character was found for 'crow' Is what happens when i try for token_id regardless of what image i try.&nbsp; But the&nbsp; !token-mod --ignore-selected --flip fliph --ids @{crow|character_id} Works with any sheet tokens so that's amazing at least. Thanks ^^&nbsp; If it's just a token taken from my library does it not have the ID of it's name or? ******** EDIT! Figured out from searching how to find Token ID from you (The Arron) long ago.&nbsp; /w gm @{selected|token_id}&nbsp; Will find the ID Than in THIS format does it work for just tokens.&nbsp; !token-mod --ids -Lb5Y2W8NbOBVLGN0nKH --flip fliph&nbsp; Thanks for all the help guys ^^ I'm super excited to try all this out.&nbsp;
1553822801

Edited 1553833489
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Mr. NumNums said: No character was found for 'crow' Is what happens when i try for token_id regardless of what image i try.&nbsp; That's the behavior I'd expect if you were typing @{crow|token_id}. As far as I know, that association doesn't work. (If you put two instances of Crow on the table, Roll20 has no idea which one it would be. @{selected|token_id} or @{target|token_id} will work (as you note).
1553832653

Edited 1553900396
The Aaron
Roll20 Production Team
API Scripter
Actually, you can put --ids anywhere, I was thinking of how Torch works. @{selected|token_id} would work, but is redundant if you leave out --ignore-selected: !token-mod --on fliph That should flip any tokens that are selected.
1553833536
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Derp. I had intended to write "@{selected|token_id} or @{target|token_id}" above. And now I have.
1554017096
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
I don't know if I've asked this before, but if I run Token Mod on a group of tokens they become deselected by the end of the script. So for instance if I need to add a status dot to 5 tokens to indicate some condition, and another alteration such as subtract a number of ht points, I must re-select them. Is this by design?
1554036034
The Aaron
Roll20 Production Team
API Scripter
That’s a feature (bug) of Roll20. &nbsp;The API has no control over selections.&nbsp;
1554046334
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Thanks. Like I said, I think I might have asked you this before. Swiss cheese brain, here.
1554665125

Edited 1554665222
Sorry, if this is clearly documented somewhere. I've looked through but can't find the information. Is there a way that I can pre-set the target for 'tokenmod' in advance without having to select it at the time? For example, I have a room full of torches lighting up the area, and next session I'm hoping to have them all turn off dramatically. I'm also aware that dynamic lighting can sometimes cause too much lag, so I'm also looking for a way to disable all 'torches' 'for emergencies' too!. I know I can go into the map layer? Or maybe Dynamic lighting? layer, select them all one by one and then run my macro... !token-mod {{ --set light_radius|0 light_dimradius|0 --off light_otherplayers }} /emas The room lights go out! ...but is there any way I can add anything like a 'character ID' into or 'character name' into the code near the top? So I don't have to select, or target something prior to me running my macro? I'm guessing that every 'Token' most likely had it's own unique ID, even if they all link to the same character. (In my case, the character is called 'Torch'). - Which may make this request impossible. Thanks again! EDIT: Oops! - I've just realised that the question above is asking pretty much the same thing! - Sorry! Will read that first!
1554665279
GiGs
Pro
Sheet Author
API Scripter
there's an --ids command which lets you declare the ids of the target tokens. I've never used it, and am going from memory, but it's definitely listed in the documentation.
1554669861

Edited 1554669956
The Aaron
Roll20 Production Team
API Scripter
As GiGs pointed out, you can specify one or more IDs with --ids: !token-mod --set something|value --ids -Jkasf22313s4 -Jk1324s4ads You could use token ids and make a long list of them after the --ids flag.&nbsp; You can use character ids as well as token ids, so you could make all those torches represent the character "Torch" and just do: !token-mod --set something|value --ids @{Torch|character_id} That makes it easier to add more torches without needing to edit a bunch of commands: !token-mod --set represents|@{Torch|character_id} Additionally, you can make the command only affect Torch tokens on the current page by combining the above technique with the --current-page command: !token-mod --set something|value --current-page --ids @{Torch|character_id} If you have your characters split across pages, you can also use --active-pages to do only the tokens on pages that have players on them. Hope that helps!
1554671686

Edited 1554671815
Perfect - Worked exactly as hoped... I now have two macros saved, which I access through a ' Chat Menu ' which look like: !token-mod --set light_radius| light_dimradius| --off light_otherplayers --ids @{torch|character_id} /w gm All room Torches now turned off !token-mod --set light_radius|60 light_dimradius|0 --on light_otherplayers --ids @{torch|character_id} /w gm All room Torches now turned on Thanks!
1554675352
The Aaron
Roll20 Production Team
API Scripter
cool.&nbsp; =D
Hi not shure why bvut my API keeps crashing evne I deinstall nad re install the scripts Idears?
1554992507
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Alexander, have you tried activating your scripts one at a time? If you can't narrow down the problem that way, you should post in the bugs forum for best response.
1555079092

Edited 1555079207
I keep having an issue trying to fire two separate instances of tokenmod in the same macro.&nbsp; I wondered if this was a normal behavior.&nbsp; I'm gonna freestyle the code just to give an example of what I'm referring to, but the premise is that I want to fire the Macro "SwapBigBad" to take a portal from the object layer and swap it with the critter on the gm layer who just came through it and closed the portal behind him.&nbsp; So I do something like this in the same Macro: 1. Macro "SwapBigBad" created on a Character Sheet named "Events Menu" in the Abilities Section 2. Click the link [Big Baddy Enters From the Portal!](~Events Menu|SwapBigBad) 3. Fires off the approx code below from the macro: !token-mod {{ &nbsp; --ids &nbsp;&nbsp;&nbsp;&nbsp; -Portal_xjbnfkdd-djdn (Some relevant token ID gathered from @{selected|token_id} for the portal) &nbsp; --set &nbsp;&nbsp;&nbsp; layer|gmlayer }} !token-mod {{ &nbsp; --ids &nbsp;&nbsp;&nbsp;&nbsp; -Critter_sndvskvjncov-5165 (Some relevant token ID gathered from @{selected|token_id} for the critter) &nbsp; --set &nbsp;&nbsp;&nbsp; layer|objects }} Now the problem is that ONE of the things work, the other usually does not if handled in the same macro call.&nbsp; Is that normal?&nbsp; Is there a workaround I'm missing?&nbsp; Is it because Comcast is horrible and causes me lag/ bad bandwidth through roll20 and discord running on the same PC?&nbsp; Help?!!!&nbsp; lol
1555080282
The Aaron
Roll20 Production Team
API Scripter
try adding --ignore-selected to both of them.
I'm no expert. But try including a DELAY of maybe 0.5 seconds between the two tokenmod codes... Just use the delay API. <a href="https://app.roll20.net/forum/post/6533907/script-delay" rel="nofollow">https://app.roll20.net/forum/post/6533907/script-delay</a>
1555080517
The Aaron
Roll20 Production Team
API Scripter
godthedj said: I'm no expert. But try including a DELAY of maybe 0.5 seconds between the two tokenmod codes... Just use the delay API. <a href="https://app.roll20.net/forum/post/6533907/script-delay" rel="nofollow">https://app.roll20.net/forum/post/6533907/script-delay</a> I'm speculating that that would only illustrate what is happening. My guess is that you have one of the two things selected when you run the command, so it becomes an argument to both commands, meaning the one that isn't selected works correctly, and the one that is selected ends up being placed on the new layer, then back on the old layer with the unselected one.
The Aaron said: try adding --ignore-selected to both of them. Yup - that did it .... Knew there was something I missed ...