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.

1667963299

Edited 1667963522
timmaugh
Pro
API Scripter
Fetch can tell you the current height, width, left, and top of a token. (Note: requires Fetch v2.0) @(selected.height) @(selected.width) @(selected.top) @(selected.left) It can even tell you the snapping increment of the page the token is on, so you could know the position of the gridlines: @(page.@(selected.pageid).snapping_increment) ZeroFrame can defer an inline roll to do modulo math using the info returned by Fetch, or MathOps could do it without deferring. MathOps version for top: {& math @(selected.top) % (@(page.@(selected.pageid).snapping_increment)*70)} ...and for left: {& math @(selected.left) % (@(page.@(selected.pageid).snapping_increment)*70)} Of course, that is to the center of the token, so if you want to align the upper left corner to the grid, you have to adjust your starting figure to account for half of the height/width. The actual upper left corner is found as: TOP : {&math @(selected.top)-(@(selected.height)/2)} LEFT: {&math @(selected.left)-(@(selected.width)/2)} Which would make the modulo operation for the upper left corner: TOP : {& math (@(selected.top)-(@(selected.height)/2)) % (@(page.@(selected.pageid).snapping_increment)*70)} LEFT:  {& math ( @(selected.left)-(@(selected.width)/2) ) % (@(page.@(selected.pageid).snapping_increment)*70)} Those numbers would tell you how far the upper left corner was displaced from aligning to the grid... so you could use them right in a TokenMod command line to move the token that far. Those numbers are "right" and "down" measurements of displacement, so to use those numbers for grid alignment, you would need to change the sign so that the token would always be moving the token up and to the left. If you would rather move it down and to the right to get it to align, you'd have to subtract those displacement numbers from the grid size of the page. To explain... imagine the token has a top displacement of 23. That means it is 23 pixels below aligning to the grid, or (putting it another way) the grid line is 23 pixels above the upper left corner. You could therefore move the token 23 pixels up to align it, or your could move it the remainder of the grid square down to align it to the next grid line. The height/width of a grid square is the portion of the equation where you see the snapping increment multiplied by 70 (the default 100% resolution): (@(page.@(selected.pageid).snapping_increment)*70) TL;DR So, working from the upper left corner, the final equation for "how far to move the token down" is: {& math  (@(page.@(selected.pageid).snapping_increment)*70)-( (@(selected.top)-(@(selected.height)/2)) % (@(page.@(selected.pageid).snapping_increment)*70))} ...and the final equation for "how far to move the token to the right" is: {& math  (@(page.@(selected.pageid).snapping_increment)*70)-( (@(selected.left)-(@(selected.width)/2)) % (@(page.@(selected.pageid).snapping_increment)*70))} REQUIRED SCRIPTS: Fetch, MathOps, TokenMod, and ZeroFrame (if you don't install MathOps after Fetch)
1667968084

Edited 1667968172
The Aaron said: There isn't, but how would you see that operating? Is there a way to get the current location or size of the token?  Assuming the token was aligned before modifying its size, if the prior size were known it would be a reasonable calculation.  I am doing this from a known starting point.  But once the token has been modified a few times, the macro no longer knows how to move the token. Currently I am modifying the size based on a selection, and it is an absolute value (i.e. not 2x or /2).  So I can't base the calculation on a scaling.
timmaugh said: Fetch can tell you the current height, width, left, and top of a token. (Note: requires Fetch v2.0) @(selected.height) @(selected.width) @(selected.top) @(selected.left) It can even tell you the snapping increment of the page the token is on, so you could know the position of the gridlines: @(page.@(selected.pageid).snapping_increment) ZeroFrame can defer an inline roll to do modulo math using the info returned by Fetch, or MathOps could do it without deferring. MathOps version for top: {& math @(selected.top) % (@(page.@(selected.pageid).snapping_increment)*70)} ...and for left: {& math @(selected.left) % (@(page.@(selected.pageid).snapping_increment)*70)} Of course, that is to the center of the token, so if you want to align the upper left corner to the grid, you have to adjust your starting figure to account for half of the height/width. The actual upper left corner is found as: TOP : {&math @(selected.top)-(@(selected.height)/2)} LEFT: {&math @(selected.left)-(@(selected.width)/2)} Which would make the modulo operation for the upper left corner: TOP : {& math (@(selected.top)-(@(selected.height)/2)) % (@(page.@(selected.pageid).snapping_increment)*70)} LEFT:  {& math ( @(selected.left)-(@(selected.width)/2) ) % (@(page.@(selected.pageid).snapping_increment)*70)} Those numbers would tell you how far the upper left corner was displaced from aligning to the grid... so you could use them right in a TokenMod command line to move the token that far. Those numbers are "right" and "down" measurements of displacement, so to use those numbers for grid alignment, you would need to change the sign so that the token would always be moving the token up and to the left. If you would rather move it down and to the right to get it to align, you'd have to subtract those displacement numbers from the grid size of the page. To explain... imagine the token has a top displacement of 23. That means it is 23 pixels below aligning to the grid, or (putting it another way) the grid line is 23 pixels above the upper left corner. You could therefore move the token 23 pixels up to align it, or your could move it the remainder of the grid square down to align it to the next grid line. The height/width of a grid square is the portion of the equation where you see the snapping increment multiplied by 70 (the default 100% resolution): (@(page.@(selected.pageid).snapping_increment)*70) TL;DR So, working from the upper left corner, the final equation for "how far to move the token down" is: {& math  (@(page.@(selected.pageid).snapping_increment)*70)-( (@(selected.top)-(@(selected.height)/2)) % (@(page.@(selected.pageid).snapping_increment)*70))} ...and the final equation for "how far to move the token to the right" is: {& math  (@(page.@(selected.pageid).snapping_increment)*70)-( (@(selected.left)-(@(selected.width)/2)) % (@(page.@(selected.pageid).snapping_increment)*70))} REQUIRED SCRIPTS: Fetch, MathOps, TokenMod, and ZeroFrame (if you don't install MathOps after Fetch) I see you answered my question before I even posted it.  Thank you!
This maybe because im an idiot, but i Know one of things folks were trying to do was use TARGET instead of SELECTED in the script. So i made a mistake while making a token action and did this&nbsp; [STATUS](!token-mod {{ &nbsp; &nbsp; --set statusmarkers|+Charm &nbsp; &nbsp; --ids @selected|token_id }}) instead of this [STATUS](!token-mod {{ &nbsp; &nbsp; --set statusmarkers|+Charm &nbsp; &nbsp; --ids @(selected|token_id} }}) These are buttons that show in chat and normally using the&nbsp;&nbsp; --ids @(selected|token_id} I would need to go in a remove the charm status on my caster. But with this&nbsp; --ids @selected|token_id&nbsp; I dont need to remove it, it targets only the creature. It works like a target.&nbsp; This may already be known but i couldnt find anything about targeting except it creates and issue !Spawn script and this little error fixes this for me. Here is the script i created for the spell i am using and it works fine&nbsp; &amp;{template:npcaction} {{rname=**Level 1: Charm Person** [Charm-Person](<a href="https://s3.amazonaws.com/files.d20.io/images/310725874/joL7JYmwMuikr8fxWSGlkw/original.png" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/310725874/joL7JYmwMuikr8fxWSGlkw/original.png</a>) "By my deeds I mean no harm, with these words I hope to charm... "Fascino Homenum"}} /w gm **You attempt to charm a humanoid you can see within range. 30ft.** /w gm **Hit STATUS, SFX &amp; STATUS on target humanoid.** /w gm [SPAWN](!Spawn{{ &nbsp; --name|Charm Person &nbsp; --fx|explode-magic &nbsp; --offset|0,0 &nbsp; --qty|1 &nbsp; --size|2,2 &nbsp; --order|toback &nbsp; --force|yes &nbsp; --expand|10,50 &nbsp; --deleteTarget|false }})[SFX](!splay Mind Control Psi by Daniele Galante)[STATUS](!token-mod {{ &nbsp; &nbsp; --set statusmarkers|+Charm &nbsp; &nbsp; --ids @selected|token_id }}) !act -1 600 --Charm Person !token-mod --ids @{selected|token_id} --set statusmarkers|+CharmPerson Maybe this will help someone...
1668020756
timmaugh
Pro
API Scripter
Hmm... you might need to do more testing to be sure, because this: --ids @(selected|token_id} isn't a Roll20 construction, nor is it a Fetch construction. In fact, it's sort of halfway between (opening paren, closing right brace), which might be why it wasn't working, before. And @selected|token_id doesn't get parsed by Roll20, so it's likely triggering something in TokenMod, but Aaron would have to weigh in on that.
Andrew K. said: When you change the size of a token, is there a way to align it to the game grid.&nbsp; I have a token that is going from huge, to medium, to large, etc.&nbsp; I can move it to align it, but I don't know the current size.&nbsp; I was wondering if there is an alignment function which I didn't see in the notes. The Aaron said: There isn't, but how would you see that operating? Scale and g or u works to resize, but getting it to re-align would actually take function AWAY from the current setting. In the current setup, if a token goes from medium (5x5) filling one square, to large (10x10) filling 4 squares, it expands in all sides to be the 10x10 filling the center point (expanding 2.5 outside of original position in all directions).&nbsp; The conundrum happens if you wanted to go from medium to large and then which 4 of 9 squares (quadrant) do you fill?&nbsp; NE, SE, NW, SW? Going from medium to huge is centered.&nbsp; You start in a single grid and end in a 3x3 grid (15x15).&nbsp; The problems arise in the even sizes - Large and Gargantuan - where you have to pick a landing quadrant.&nbsp; Because of this, it is better to enlarge and move than to have token-mod move for you (token-mod has to have precise movement, and it can't guess where you want to go).&nbsp; You could, perhaps, do a macro with a prompt however.&nbsp; I'm far too tired to explain the details, but something like ?{Once enlarged/ reduced, where do you want the token to land?|Center, #0g #0g|NE, #1g #1g|SE, #1g #-1g|SW, #-1g #-1g|NW, #-1g #1g} Or something to that effect.&nbsp; Leaving the rest of the macro to someone better suited to it.
1668109735
The Aaron
Roll20 Production Team
API Scripter
timmaugh said: And @selected|token_id doesn't get parsed by Roll20, so it's likely triggering something in TokenMod, but Aaron would have to weigh in on that. That's somebody's typo.&nbsp; It would need to be @{selected|token_id}.&nbsp; TokenMod will ignore @selected|token_id.
1668109905
The Aaron
Roll20 Production Team
API Scripter
Wolf Thunderspirit said: Andrew K. said: When you change the size of a token, is there a way to align it to the game grid.&nbsp; I have a token that is going from huge, to medium, to large, etc.&nbsp; I can move it to align it, but I don't know the current size.&nbsp; I was wondering if there is an alignment function which I didn't see in the notes. The Aaron said: There isn't, but how would you see that operating? Scale and g or u works to resize, but getting it to re-align would actually take function AWAY from the current setting. In the current setup, if a token goes from medium (5x5) filling one square, to large (10x10) filling 4 squares, it expands in all sides to be the 10x10 filling the center point (expanding 2.5 outside of original position in all directions).&nbsp; The conundrum happens if you wanted to go from medium to large and then which 4 of 9 squares (quadrant) do you fill?&nbsp; NE, SE, NW, SW? Going from medium to huge is centered.&nbsp; You start in a single grid and end in a 3x3 grid (15x15).&nbsp; The problems arise in the even sizes - Large and Gargantuan - where you have to pick a landing quadrant.&nbsp; Because of this, it is better to enlarge and move than to have token-mod move for you (token-mod has to have precise movement, and it can't guess where you want to go).&nbsp; You could, perhaps, do a macro with a prompt however.&nbsp; I'm far too tired to explain the details, but something like ?{Once enlarged/ reduced, where do you want the token to land?|Center, #0g #0g|NE, #1g #1g|SE, #1g #-1g|SW, #-1g #-1g|NW, #-1g #1g} Or something to that effect.&nbsp; Leaving the rest of the macro to someone better suited to it. That's exactly the case I was thinking about.&nbsp; If I did anything, I'd add something like --snap-X where X is (nw,ne,sw,se, etc), and would adjust the token to align to the grid at that corner.&nbsp; There's a bit of a paradigm shift doing that though, as what that means might change depending on the order you do certain operations.
1668115676

Edited 1668115710
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
The Aaron said: That's exactly the case I was thinking about.&nbsp; If I did anything, I'd add something like --snap-X where X is (nw,ne,sw,se, etc), and would adjust the token to align to the grid at that corner.&nbsp; There's a bit of a paradigm shift doing that though, as what that means might change depending on the order you do certain operations. Not to mention how one would account for hex or iso grids.
1668116908
timmaugh
Pro
API Scripter
There's probably enough there for it's own script. What I proposed with the metatoolbox would work for square grids, and there was enough info there to extrapolate the directional movement (negating the vertical displacement to move it "north" could handle both "nw" and "ne", depending on how you handled the horizontal displacement), but it was a lot of extra verbiage, for sure. Some sort of alignment script could offer handles for what corner of the token to align in what direction, and could take the grid style into account.
1668130461

Edited 1668130561
timmaugh said: There's probably enough there for it's own script. What I proposed with the metatoolbox would work for square grids, and there was enough info there to extrapolate the directional movement (negating the vertical displacement to move it "north" could handle both "nw" and "ne", depending on how you handled the horizontal displacement), but it was a lot of extra verbiage, for sure. Some sort of alignment script could offer handles for what corner of the token to align in what direction, and could take the grid style into account. And thus, yet another script is born.&nbsp; lmao.&nbsp; HAPPY BIRTHDAY!&nbsp; Tim and Aaron ... go make a baby ... lmao. All kidding aside though, I honestly don't see the need to do it.&nbsp; a simple tap of the token and it aligns to the grid you choose after resizing.
I dont know why it works but as a button in a spell they do work properly with no errors showing up&nbsp;
This maybe because im an idiot, but i Know one of things folks were trying to do was use TARGET instead of SELECTED in the script. So i made a mistake while making a token action and did this&nbsp; [STATUS](!token-mod {{ &nbsp; &nbsp; --set statusmarkers|+Charm &nbsp; &nbsp; &nbsp;--ids @selected|token_id }}) instead of this [STATUS](!token-mod {{ &nbsp; &nbsp; --set statusmarkers|+Charm &nbsp; &nbsp; &nbsp;--ids @(selected|token_id} }}) These are buttons that show in chat and normally using the&nbsp;&nbsp; --ids @(selected|token_id}&nbsp; I would need to go in a remove the charm status on my caster. I have ran many tests on various spells as buttons in chat in it works with absolutely no errors or issues with api's i have??
--ids @(selected|token_id} was atypo --ids @{selected|token_id} is what it should have been
1668232320
The Aaron
Roll20 Production Team
API Scripter
The reason it has been working is because TokenMod always operates on all selected tokens unless you specify --ignore-selected or have a @{target|...} as part of the command.&nbsp;
I can't understand why I can't parse a token ID directly anymore: !token-mod {{ --ids @{Strahd von Zarovich|token_id} --ignore-selected --set bar3_value|@{Strahd von Zarovich|speed} }} gets me this: No attribute was found for @{Strahd von Zarovich|token_id}
1668496721

Edited 1668497187
The Aaron
Roll20 Production Team
API Scripter
Use character_id Characters don't have a token_id because there is a one to many relationship between characters and the tokens that represent them, the system wouldn't know which id to use. TokenMod will take a character_id and find all graphics representing that character to apply the command to. You may also want to supply --current-page or --active-pages to only target graphics on your current page or pages with players on them respectively.&nbsp;
1668532995

Edited 1668533322
The Aaron said: Use character_id Characters don't have a token_id because there is a one to many relationship between characters and the tokens that represent them, the system wouldn't know which id to use. TokenMod will take a character_id and find all graphics representing that character to apply the command to. You may also want to supply --current-page or --active-pages to only target graphics on your current page or pages with players on them respectively.&nbsp; I didn't know you could use character_id , I thought TokenMod was token_id only.&nbsp; Interesting...&nbsp; That may be a blurb you want to add to the --help file.&nbsp; But also recommend it only in using direct references like mine, and how to use the --ignore-selected , --curent-page or --active-page .&nbsp; I think one of the most difficult things to do sometimes is isolating the tokens you want to effect without using @{selected| or @{target| (especially in a character sheet or global macro, where only certain tokens/ characters would be under the macro effect). And, since I wanted this to be a global-effecting macro, its actually OK to apply to all tokens throughout module.&nbsp; It's precisely what I want to happen.
1668533235
The Aaron
Roll20 Production Team
API Scripter
Ah, good point.&nbsp; It is there under the two page restrictions: --current-page &nbsp;-- Only modifies tokens on the calling player's current page. This is particularly useful when passing character_ids to&nbsp; --ids . --active-pages &nbsp;-- Only modifies tokens on pages where there is a player or the GM. This is particularly useful when passing character_ids to&nbsp; --ids . But it's missing under the --ids option and the Token Specification section.
The Aaron said: Ah, good point.&nbsp; It is there under the two page restrictions: --current-page &nbsp;-- Only modifies tokens on the calling player's current page. This is particularly useful when passing character_ids to&nbsp; --ids . --active-pages &nbsp;-- Only modifies tokens on pages where there is a player or the GM. This is particularly useful when passing character_ids to&nbsp; --ids . But it's missing under the --ids option and the Token Specification section. Yeah, not that you didn't do a good job thoroughly explaining to folks about everything the API does, but the "Affected Tokens" section could all be brought together in it's own very clear section. On that note, the UDL/ LDL sections, since Roll20 has deprecated LDL, could probably be separated now for distinction, making LDL a footnote for those still using it, after UDL is described in detail. I wonder how long LDL is actually going to remain in Roll20?&nbsp; At that time, all the LDL functionality could be trimmed out of TokenMod to speed it up. Gotta admit Aaron, been in Foundry lately and kinda miss your presence there.&nbsp; lol.
So weird behavior, and I thought I had an understanding of how things work, but apparently ... I don't I thought that bar1, bar1_value, or the like would also Link the corresponding attribute to the bar.&nbsp; But, it seems to only be concerned with values? &lt;- All attributes are "None" after setting. I wondered if we could get a combination Boolean/ Attribute Declaration in the bars: --set&nbsp; bar1_link|true|hp bar2_link|false|speed bar3_link|false|fly_speed
From the TokenMod help handout: Attribute Name These are resolved from the represented character id. If the token doesn't represent a character, these will be ignored. If the Attribute Name specified doesn't exist for the represented character, the link is unchanged. You can clear a link by passing a blank Attribute Name. Available Attribute Name Properties: bar1_link bar2_link bar3_link Here is setting the represents to the character Bob and setting bar1 to be the npc hit points attribute. !token-mod --set represents|@{Bob|character_id} bar1_link|npc_HP Here is clearing the link for bar3: !token-mod --set bar3_link| Text These can be pretty much anything. If your value has spaces in it, you need to enclose it in ' or ". Available Text Properties: name tooltip bar1_value bar2_value bar3_value bar1_current bar2_current bar3_current bar1_max bar2_max bar3_max bar1 bar2 bar3 bar1_reset bar2_reset bar3_reset Setting a token's name to "Sir Thomas" and bar1 value to 23. !token-mod --set name|"Sir Thomas" bar1_value|23 Setting a bar to a numeric value will be treated as a relative change if prefaced by&nbsp; + ,&nbsp; - ,&nbsp; * , or&nbsp; / , or will be explicitly set when prefaced with a&nbsp; = . If you are setting a bar value, you can append a&nbsp; ! &nbsp;to the value to force it to be bounded between&nbsp; 0 &nbsp;and&nbsp; max &nbsp;for the bar. bar1 ,&nbsp; bar2 &nbsp;and&nbsp; bar3 &nbsp;are special. Any value set on them will be set in both the&nbsp; _value &nbsp;and&nbsp; _max &nbsp;fields for that bar. This is most useful for setting hit points, particularly if the value comes from an inline roll. !token-mod --set bar1|[[3d6+8]] bar1_reset ,&nbsp; bar2_reset &nbsp;and&nbsp; bar3_reset &nbsp;are special. Any value set on them will be ignored, instead they will set the&nbsp; _value &nbsp;field for that bar to whatever the matching&nbsp; _max &nbsp;field is set to. This is most useful for resetting hit points or resource counts like spells. (The&nbsp; | &nbsp;is currently still required.) !token-mod --set bar1_reset| bar3_reset|
Jarren said: From the TokenMod help handout: Attribute Name These are resolved from the represented character id. If the token doesn't represent a character, these will be ignored. If the Attribute Name specified doesn't exist for the represented character, the link is unchanged. You can clear a link by passing a blank Attribute Name. Available Attribute Name Properties: bar1_link bar2_link bar3_link Here is setting the represents to the character Bob and setting bar1 to be the npc hit points attribute. !token-mod --set represents|@{Bob|character_id} bar1_link|npc_HP Here is clearing the link for bar3: !token-mod --set bar3_link| Text These can be pretty much anything. If your value has spaces in it, you need to enclose it in ' or ". Available Text Properties: name tooltip bar1_value bar2_value bar3_value bar1_current bar2_current bar3_current bar1_max bar2_max bar3_max bar1 bar2 bar3 bar1_reset bar2_reset bar3_reset Setting a token's name to "Sir Thomas" and bar1 value to 23. !token-mod --set name|"Sir Thomas" bar1_value|23 Setting a bar to a numeric value will be treated as a relative change if prefaced by&nbsp; + ,&nbsp; - ,&nbsp; * , or&nbsp; / , or will be explicitly set when prefaced with a&nbsp; = . If you are setting a bar value, you can append a&nbsp; ! &nbsp;to the value to force it to be bounded between&nbsp; 0 &nbsp;and&nbsp; max &nbsp;for the bar. bar1 ,&nbsp; bar2 &nbsp;and&nbsp; bar3 &nbsp;are special. Any value set on them will be set in both the&nbsp; _value &nbsp;and&nbsp; _max &nbsp;fields for that bar. This is most useful for setting hit points, particularly if the value comes from an inline roll. !token-mod --set bar1|[[3d6+8]] bar1_reset ,&nbsp; bar2_reset &nbsp;and&nbsp; bar3_reset &nbsp;are special. Any value set on them will be ignored, instead they will set the&nbsp; _value &nbsp;field for that bar to whatever the matching&nbsp; _max &nbsp;field is set to. This is most useful for resetting hit points or resource counts like spells. (The&nbsp; | &nbsp;is currently still required.) !token-mod --set bar1_reset| bar3_reset| That's so weird - bc I thought I looked thoroughly through the --hep and was looking in the text and boolean sections not finding it, I also thought bar1_link already was a thing too, so I couldn't figure out why I couldn't find it.&nbsp; Thx for being an extra set of eyes @Jarren!
I think it's&nbsp;Aura/Tint HealthColors doing it but does anyone know how i can make it only put the death marker on npc's at 0 hp but not pc's?
Mootjester said: I think it's&nbsp;Aura/Tint HealthColors doing it but does anyone know how i can make it only put the death marker on npc's at 0 hp but not pc's? I'm not sure if you're referring to something else in the TokenMod script thread, but the command to toggle the DeathMarker for PCs is: !aura deadPC Or to pull up the AuraTint Healthcolors menu, just use&nbsp; !aura
1671234507

Edited 1671234990
Mike W.
Pro
Sheet Author
I have, what I beleive, is a very simple macro. Using your Help documentation I was able to create the emacro they way I want except for one thing: I cannot leave out a value for the Token Marker. Sometimes I want a nuberic value from 1 to 9, other timea I want no value at all - such as just the default Token Marker image selected. !token-mod --set statusmarkers|!?{Marker|Burning,Burning|Dead,dead|Bleeding,red|Dying,half-heart|Frightened,blue|Helpless,interdiction|Nauseated,pink|On Fire,half-haze|Sleep,sleepy|Slowed,snail|Staggard,brown|Summoned,yellow}:?{Numeric 1-9| } Note: Token Markers Burning and Flying are custom Token Markers. Also if the Token Mark already exist, with a value or not, I am using the ! so it will remove the Token Marker if I select it again. However, to remove an existing Token Marker with a value requiers you to enter that value again. I woudl like it just to remove the Token Marker without having to eneter that value again - if possible. So is this possible? Thanks.
Mike W. said: I have, what I beleive, is a very simple macro. Using your Help documentation I was able to create the emacro they way I want except for one thing: I cannot leave out a value for the Token Marker. Sometimes I want a nuberic value from 1 to 9, other timea I want no value at all - such as just the default Token Marker image selected. !token-mod --set statusmarkers|!?{Marker|Burning,Burning|Dead,dead|Bleeding,red|Dying,half-heart|Frightened,blue|Helpless,interdiction|Nauseated,pink|On Fire,half-haze|Sleep,sleepy|Slowed,snail|Staggard,brown|Summoned,yellow}:?{Numeric 1-9| } Note: Token Markers Burning and Flying are custom Token Markers. Also if the Token Mark already exist, with a value or not, I am using the ! so it will remove the Token Marker if I select it again. However, to remove an existing Token Marker with a value requiers you to enter that value again. I woudl like it just to remove the Token Marker without having to eneter that value again - if possible. So is this possible? Thanks. Hmmm ... couple of things ... first off, Burning and Flying should be directly contrived if they are Custom Markers; example Burning:0023489 &nbsp; You can get the exact reference from !token-mod --help ; all of your game's standard and custom markers ids will be gathered there Secondly, I would just list all possible values, including the 0 value, for clears !token-mod {{ --set statusmarkers|!?{Marker|Burning,Burning: 0023489 |Dead,dead|Bleeding,red|Dying,half-heart |Flying,Flying:0086794 |Frightened,blue|Helpless,interdiction|Nauseated,pink|On Fire,half-haze|Sleep,sleepy|Slowed,snail|Staggard,brown|Summoned,yellow}:?{Numeric 0-9|0|1|2|3|4|5|6|7|8|9} }} There's some more complicated things you 'can do', but it all depends on how you are using the macros.&nbsp; I wouldn't recommend this to most people though, it can get complicated: ?{Are you Adding a marker?|Yes,!|No,!.}token-mod {{ --on statusmarkers|?{Marker|Burning, Burning:0023489 |Dead,dead|Bleeding,red|Dying,half-heart |Flying,Flying:0086794 |Frightened,blue|Helpless,interdiction|Nauseated,pink|On Fire,half-haze|Sleep,sleepy|Slowed,snail|Staggard,brown|Summoned,yellow}:?{Numeric 0-9|0|1|2|3|4|5|6|7|8|9} }} ?{Are you Removing a marker?|Yes,!|No,!.}token-mod {{ --off statusmarkers|?{Marker|Burning, Burning:0023489 |Dead,dead|Bleeding,red|Dying,half-heart |Flying,Flying:0086794 |Frightened,blue|Helpless,interdiction|Nauseated,pink|On Fire,half-haze|Sleep,sleepy|Slowed,snail|Staggard,brown|Summoned,yellow}:0 }} I've had the above type of macro work with mixed results.&nbsp; It never works with reference calls (%/%.) or attributes (@/@.), and sometimes (!/!.) doesn't work in sheets' styled portions (works from the attributes and abilities tab or global macros).&nbsp; The main thing you have to remember is that ! has to be in the unstylized chat (roll macros) and has to be on the first line. ! will call something into being (almost exclusively, as I understand it - API calls) !. will ignore all text up to a carriage return or %NEWLINE% call
1672986629

Edited 1672986659
The Aaron said: Sorry Doug!&nbsp; I missed this message, probably due to that "every 50th reply" bug on the forum. I'll need to try this out a bit.&nbsp; There are been a few reports of issues with the bars in the last few weeks, I'm not clear if it's a change from Roll20 or something to do with a change I made a little while ago to cause bar value changes to trigger sheet workers for linked attributes.&nbsp; If you could test out version 0.8.74 ( <a href="https://github.com/Roll20/roll20-api-scripts/blob/master/TokenMod/0.8.74/TokenMod.js" rel="nofollow">https://github.com/Roll20/roll20-api-scripts/blob/master/TokenMod/0.8.74/TokenMod.js</a> ), and see if that works, it would help me track down if my change in 0.8.75 caused this issue.&nbsp; &nbsp;Otherwise, I can try and reproduce this later tonight. Hi Aaron. This issue still remains. You told us to test version 0.8.74, but Doug wasn't entirely successful with that version. Could a previous version work better?
1673117321

Edited 1673118439
I'm trying to create a script to be used as a token action to automate switching vison between two tokens. In D&amp;D 5E, a spellcaster can have a creature that acts as their&nbsp; familiar , and has the ability to see through the familiar's eyes but while doing so are themselves blinded. I've created a token for the familiar and given control of it to the spellcaster's player and created a couple of token actions using TokenMod scripts to turn it's vision on and off. What I'd like is for the spellcaster's token vison to be turned off when the familiar's vision is turned on, and vice-versa for when it is turned off. IOW, I want to combine these two macros into one for allowing vision through the familiar's eyes: !token-mod {{ &nbsp; --set &nbsp; &nbsp; bright_vision|on &nbsp; &nbsp; night_vision|on &nbsp; &nbsp; night_vision_distance|120 &nbsp; &nbsp; night_vision_effect|nocturnal &nbsp; &nbsp; has_directional_bright_light|off &nbsp; &nbsp; directional_bright_light_center|360 &nbsp; &nbsp; directional_bright_light_total|0 &nbsp; &nbsp; light_color|transparent }} !token-mod {{ &nbsp; --set &nbsp; &nbsp; bright_vision|off &nbsp; &nbsp; night_vision|off --ids @{Schlitz|character_id} }} And then combine these two for restoring vision to the spellcaster token: !token-mod {{ --set bright_vision|off night_vision|off }} !token-mod {{ --set bright_vision|on night_vision|on night_vision_distance|60 night_vision_effect|nocturnal has_directional_bright_light|off directional_bright_light_center|360 directional_bright_light_total|0 light_color|transparent --ids @{Schlitz|character_id} }}
1673119632

Edited 1673119679
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
What's the problem with just putting the two token-mod commands into one action? Here's the one I use, employing a&nbsp; Chat Menu : /w "@{selected|character_name}" &amp;{template:npcaction} {{rname=Familiar Perception-Clancy}} {{description=[See Through Familiar's Eyes](!token-mod --set has_bright_light_vision|on has_night_vision|on night_vision_distance|60 light_angle|360&nbsp; --ignore-selected --current-page --ids -MQ-79zJkYVkoq5ieNYk !token-mod --set has_bright_light_vision|off has_night_vision|off light_angle|360 --ignore-selected --current-page --ids @{Clancey Quinnlevan|character_id}) [See Through PCs Eyes](!token-mod --set has_bright_light_vision|off has_night_vision|off light_angle|360 --ignore-selected --current-page&nbsp; --ids -MQ-79zJkYVkoq5ieNYk !token-mod --set has_bright_light_vision|on has_night_vision|on night_vision_distance|60 light_angle|360 --ignore-selected --current-page --ids @{Clancey Quinnlevan|character_id})}}
Cristiano Grass said: The Aaron said: Sorry Doug!&nbsp; I missed this message, probably due to that "every 50th reply" bug on the forum. I'll need to try this out a bit.&nbsp; There are been a few reports of issues with the bars in the last few weeks, I'm not clear if it's a change from Roll20 or something to do with a change I made a little while ago to cause bar value changes to trigger sheet workers for linked attributes.&nbsp; If you could test out version 0.8.74 ( <a href="https://github.com/Roll20/roll20-api-scripts/blob/master/TokenMod/0.8.74/TokenMod.js" rel="nofollow">https://github.com/Roll20/roll20-api-scripts/blob/master/TokenMod/0.8.74/TokenMod.js</a> ), and see if that works, it would help me track down if my change in 0.8.75 caused this issue.&nbsp; &nbsp;Otherwise, I can try and reproduce this later tonight. Hi Aaron. This issue still remains. You told us to test version 0.8.74, but Doug wasn't entirely successful with that version. Could a previous version work better? Specifically, the issue was with one bar not switching back; The Aaron &nbsp;said: Sorry Doug!&nbsp; I missed this message, probably due to that "every 50th reply" bug on the forum. &lt;snip&gt; Sorry for taking so long. I tried the 0.8.74 script and when dropping wildshape, it does change the bar 1 and 2 links properly but not bar 3. The speed from the last wildshape still sticks. With 0.8.75 version and when dropping wildshape, it changes the token side and size ok, but somewhere along the line it altered the hp, ac and speed of the original character sheet to that of the wildshape.
1673120798

Edited 1673120913
I tried that and couldn't get it to work, but after looking at your example I figured out why: I needed to add&nbsp; --ignore-selected &nbsp;before&nbsp; --ids @{Schlitz|character_id}. &nbsp;Both actions now work perfectly. Thanks&nbsp; keithcurtis &nbsp;! keithcurtis said: What's the problem with just putting the two token-mod commands into one action? Here's the one I use, employing a&nbsp; Chat Menu : /w "@{selected|character_name}" &amp;{template:npcaction} {{rname=Familiar Perception-Clancy}} {{description=[See Through Familiar's Eyes](!token-mod --set has_bright_light_vision|on has_night_vision|on night_vision_distance|60 light_angle|360&nbsp; --ignore-selected --current-page --ids -MQ-79zJkYVkoq5ieNYk !token-mod --set has_bright_light_vision|off has_night_vision|off light_angle|360 --ignore-selected --current-page --ids @{Clancey Quinnlevan|character_id}) [See Through PCs Eyes](!token-mod --set has_bright_light_vision|off has_night_vision|off light_angle|360 --ignore-selected --current-page&nbsp; --ids -MQ-79zJkYVkoq5ieNYk !token-mod --set has_bright_light_vision|on has_night_vision|on night_vision_distance|60 light_angle|360 --ignore-selected --current-page --ids @{Clancey Quinnlevan|character_id})}}
Rick A. said: I'm trying to create a script to be used as a token action to automate switching vison between two tokens. In D&amp;D 5E, a spellcaster can have a creature that acts as their&nbsp; familiar , and has the ability to see through the familiar's eyes but while doing so are themselves blinded. I've created a token for the familiar and given control of it to the spellcaster's player and created a couple of token actions using TokenMod scripts to turn it's vision on and off. What I'd like is for the spellcaster's token vison to be turned off when the familiar's vision is turned on, and vice-versa for when it is turned off. Rick A. said: I tried that and couldn't get it to work, but after looking at your example I figured out why: I needed to add&nbsp; --ignore-selected &nbsp;before&nbsp; --ids @{Schlitz|character_id}. &nbsp;Both actions now work perfectly. Here's the simple TokenMod macro that I use (placed as a Token Action on the familiar's character sheet): !token-mod --ids @{PCNAME|character_id}&nbsp; @{FAMILIARNAME|character_id} --flip has_bright_light_vision /w gm PCNAME &amp; FAMILIARNAME vision swapped It's possible that both familiar and PC could have their vision 'on' or 'off' at the same time, in which case my player is going to tell me that something weird has happened and their view hasn't switched, or that they suddenly can't see anything at all.&nbsp; I also have a Dummy Account running at the same time, so typically I would notice as well (even though I have several player's vision enabled... it's still noticeable).
Can&nbsp; Tokenmod call an ability from a caster and have an effect fire upon a enemy for example this below: &amp;{template:npcaction} {{rname=**Level 1: Hail of Thorns** [Hail-of-Thorns](<a href="https://s3.amazonaws.com/files.d20.io/images/317939119/lyGGjwPOHuH6Ir5glKPs4Q/original.png" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/317939119/lyGGjwPOHuH6Ir5glKPs4Q/original.png</a>) "Nature infuse and death do spawn, rain down on my foes a hail of thorns,"Tempestas di Spinas"}} /w gm **The next time you hit a creature with a ranged weapon attack before the spell ends, this spell creates a rain of thorns that sprouts from your ranged weapon or ammunition. In addition to the normal effect of the attack, the target of the attack and each creature within 5 feet of it must make a Dexterity saving throw. A creature takes 1d10 piercing damage on a failed save, or half as much damage on a successful one.** /w gm **Hit EFFECT on target creature.** /w gm [EFFECT](~selected|Hail-of-Thorns-Effect) !token-mod --ids @{selected|token_id} --set statusmarkers|+HailofThorns|+Concentration&nbsp; !act -1 10 --Hail of Thorns&nbsp; The ability from [EFFECT] would fire on the foe&nbsp; when the foe is chosen and the EFFECT button hit. Any help would be appreciated
You might take a look at SmartAOE API/Mod Script.&nbsp;
Hi all, This has properly been asked a few times before, but can tokenmod set the play/pause and loop effects on an animated token? Thanks again for a great mod
1674519198
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Hi GM! Unfortunately, Mod Scripts cannot currently affect animation settings: start, stop or looping.
1675293499

Edited 1675293739
Hi!&nbsp; I am wondering why token mod in my games has problem with getting bar value negative? !token-mod --set bar2_value|[[[[@{selected|bar2}]]- [[6]]]] When the result in above is positive all goes fine but when the result should be negative the bar changes in a weird result. Screenshot #1 below Engelhart has 5 HP token mod&nbsp;subtracts 6 from 5 result should be -1 but it's +4. Screenshot #2 token mod&nbsp;subtracts 6 from 4 result should be -2 but it's +2.
1675294841

Edited 1675295609
The Aaron
Roll20 Production Team
API Scripter
It thinks you want a relative change. Try proceeding it with an = to set.&nbsp; Specifically, this: !token-mod --set bar2_value|[[[[@{selected|bar2}]]- [[6]]]] is resolving to: !token-mod --set bar2_value|-4 Which says "reduce bar2 by 4", which is how you end up with 6-4 = 2 You could just write: !token-mod --set bar2_value|-[[6]] and it will deduct 6 from bar2.&nbsp; It doesn't need to be in an inline roll either.&nbsp; You can even append a !: !token-mod --set bar2_value|-6! and it will bound the value between 0 and bar2_max. If you want to set it to a calculated value that might be negative, you can precede it with =: !token-mod --set bar2_value|=[[[[@{selected|bar2}]]- [[6]]]] which might resolve to: !token-mod --set bar2_value|=-4 explicitly setting it to the value -4.
Thank you Aaron! The "=" is the key :) !token-mod --set bar2_value|=[[[[@{selected|bar2}]]- [[6]]]]
1675355225
The Aaron
Roll20 Production Team
API Scripter
Good to hear! I might suggest using: !token-mod --set bar2_value|-[[6]]! in general, as it will support multiple tokens at the same time (so, fireball damage, for example).&nbsp; The way you have it will give unexpected results if you have more than one token selected (@{selected|...} will get evaluated for the "first" selected token before the command is sent to the Mod Script for processing).
Question :&nbsp; Can token mod hadle the opacity of the auras ? Like !token-mod --set aura1_color|#ff00050
1675555471
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Lionel V. said: Question :&nbsp; Can token mod hadle the opacity of the auras ? Like !token-mod --set aura1_color|#ff00050 Doesn't look like it. I'm shocked! BTW, You do not need the "#". And you would need one more character, transparency on #rgb is 2 characters.
1675564747
The Aaron
Roll20 Production Team
API Scripter
I don't think you can adjust opacity on auras. If you can, I can certainly add that.&nbsp;
1675998615
Pat
Pro
API Scripter
The Aaron said: I don't think you can adjust opacity on auras. If you can, I can certainly add that.&nbsp; You can set opacity on auras, at least manually, just like the other SVG shapes, you add another pair of hex codes and viola. One of my players uses it for their "twilight" effect, dark color, but very faded.&nbsp;
1676002341
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
I use this a lot. Auras accept rgba through the GUI.
1676002430
The Aaron
Roll20 Production Team
API Scripter
I'll be darned!&nbsp; How did I not know this!&nbsp; I'll get that added to TokenMod.
I apologize if this has been asked, but I have not been able to find a definitive answer so far. Can Token Mod add abilities to a character sheet? I have macros that I want to deploy as multiple abilities I.E. Dexterity Skills, Perception Skills. At the moment I have to copy, paste sets of data after generating the Ability. However if Token Mod could then I could use it to Add and name the ability then place the Macro under each one using a set of Token Mod commands. It's more of a time saver, I realize that, but it would certainly be convenient. With the above being said. This API is terrific and I have used it for many a thing.Thank you The Aaron for your continued support of the players, GMs and Roll20. I do agree with the Feature Request to hire you. May you continue to have a more and more comfortable life and increased Karma. Here is an Example: Ability Name: 3-Knowledge &amp;{template:default} {{name = Fujin Dice}} /w gm &amp;{template:default} {{name= Knowledge}} {{Knowledge = [[d6! +2d6]] {{Business = [[d6!+ 4d6]] }} {{Languages = [[d6!+ 4d6]] }} {{Medicine = [[d6!+ 4d6]] }} {{Navigation = [[d6!+ 5d6]] }} {{Scholar = [[d6! + 4d6]] }} {{Tech = [[d6! +5d6]] }}
1676269558
Andrew R.
Pro
Sheet Author
I don’t think TokenMod can do what you want, because it’s designed to modify Tokens not Character Sheets (except through linked Attributes).&nbsp; However, I suspect that ScriptCards can do what you want. I haven’t needed those parts of ScriptCards yet, but it’s very capable and flexible.&nbsp;
I think what you are looking for is CharUtils , another script by The Aaron. It allows you to copy Abilities from one character to another.