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.

February 06 (6 years ago)
vÍnce
Pro
Sheet Author

Aaron has issues... ;-P

February 06 (6 years ago)
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
February 06 (6 years ago)


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.

February 07 (6 years ago)
The Aaron
Roll20 Production Team
API Scripter

yup

February 21 (6 years ago)

Any updates on the elevation code?  Or on the changes to Roll20 Dynamic Lighting/ how it effects TokenMod?

February 21 (6 years ago)
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?

February 23 (6 years ago)

I think peeps were talking about something with auras?

February 23 (6 years ago)
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.

March 04 (6 years ago)
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
}}
March 06 (6 years ago)
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.

March 06 (6 years ago)
The Aaron
Roll20 Production Team
API Scripter

What Keith said. 

March 09 (6 years ago)
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.

March 09 (6 years ago)
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. 

March 09 (6 years ago)

Anyone else having issue with tokenmod not adding negative numbers in the lightdim with the dropdown list for light?

March 09 (6 years ago)
The Aaron
Roll20 Production Team
API Scripter

Can you give an example of the command you’re running that isn’t working?

March 09 (6 years ago)


!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}

March 19 (6 years ago)
The Aaron
Roll20 Production Team
API Scripter

Ok, sorry for the delay.  I've tracked down this issue and fixed it in the latest pull request:  https://github.com/shdwjk/Roll20API/blob/master/TokenMod/TokenMod.js


March 19 (6 years ago)
The Aaron
Roll20 Production Team
API Scripter

Update v0.8.44 -- Fixed bug with setting negative numbers as values. (Thanks Kilter)

March 28 (6 years ago)
The Aaron
Roll20 Production Team
API Scripter

This update is now live.

March 28 (6 years ago)

Thanks Aaron, looks to be working.

March 28 (6 years ago)
The Aaron
Roll20 Production Team
API Scripter

No problem! Thanks for pointing me toward it. 

Hi i have a question. 
I've been trying to figure out how to 
"!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. 
Is this able to be done? 
and if so how? I'm very much stumped. 

March 28 (6 years ago)
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.

March 28 (6 years ago)
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 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 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 TypeError: Cannot read property 'substring' of undefined 
How do i figure out the token's id number? 

!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. 

Do i have to designate a token ID by some other means? 

March 28 (6 years ago)

Edited March 28 (6 years ago)
The Aaron
Roll20 Production Team
API Scripter

--ids must always be the last part of the command.  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}
March 29 (6 years ago)
keithcurtis
Forum Champion
Marketplace Creator
API Scripter


The Aaron said:

--ids must always be the last part of the command. 

Does that mean that the help example is incorrect?

!token-mod --ids -Jbz-mlHr1UXlfWnGaLh -JbjeTZycgyo0JqtFj-r -JbjYq5lqfXyPE89CJVs --on showname showplayers_name

March 29 (6 years ago)

Edited March 29 (6 years ago)
No character was found for 'crow'

Is what happens when i try for token_id regardless of what image i try. 

But the !token-mod --ignore-selected --flip fliph --ids @{crow|character_id}

Works with any sheet tokens so that's amazing at least. Thanks ^^ 

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. 

/w gm @{selected|token_id} 

Will find the ID
Than in THIS format does it work for just tokens. 

!token-mod --ids -Lb5Y2W8NbOBVLGN0nKH --flip fliph 

Thanks for all the help guys ^^
I'm super excited to try all this out. 
March 29 (6 years ago)

Edited March 29 (6 years ago)
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. 


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).

March 29 (6 years ago)

Edited March 29 (6 years ago)
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.

March 29 (6 years ago)
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.

March 31 (6 years ago)
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?

March 31 (6 years ago)
The Aaron
Roll20 Production Team
API Scripter

That’s a feature (bug) of Roll20.  The API has no control over selections. 

March 31 (6 years ago)
keithcurtis
Forum Champion
Marketplace Creator
API Scripter

Thanks. Like I said, I think I might have asked you this before. Swiss cheese brain, here.

April 07 (6 years ago)

Edited April 07 (6 years ago)

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!


April 07 (6 years ago)
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.

April 07 (6 years ago)

Edited April 07 (6 years ago)
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.  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!



April 07 (6 years ago)

Edited April 07 (6 years ago)

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!
April 07 (6 years ago)
The Aaron
Roll20 Production Team
API Scripter

cool.  =D

Hi not shure why bvut my API keeps crashing evne I deinstall nad re install the scripts Idears?

April 11 (6 years ago)
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.

April 12 (6 years ago)

Edited April 12 (6 years ago)

I keep having an issue trying to fire two separate instances of tokenmod in the same macro.  I wondered if this was a normal behavior.  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.  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 {{
  --ids
     -Portal_xjbnfkdd-djdn (Some relevant token ID gathered from @{selected|token_id} for the portal)
  --set
    layer|gmlayer
}}
!token-mod {{
  --ids
     -Critter_sndvskvjncov-5165 (Some relevant token ID gathered from @{selected|token_id} for the critter)
  --set
    layer|objects
}}

Now the problem is that ONE of the things work, the other usually does not if handled in the same macro call.  Is that normal?  Is there a workaround I'm missing?  Is it because Comcast is horrible and causes me lag/ bad bandwidth through roll20 and discord running on the same PC?  Help?!!!  lol

April 12 (6 years ago)
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.

https://app.roll20.net/forum/post/6533907/script-delay

April 12 (6 years ago)
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.

https://app.roll20.net/forum/post/6533907/script-delay


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.

April 12 (6 years ago)


The Aaron said:

try adding --ignore-selected to both of them.


Yup - that did it ....

Knew there was something I missed ...