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.

December 16 (1 year ago)
The Aaron
Roll20 Production Team
API Scripter

I don't believe status markers can be webm files.  Status Markers get uploaded on the Game Details Page.  There is then a menu of them you can choose by name.  It sounds like you're setting the token's image to a webm file.  That works, but the API doesn't have the ability to cause them to play.  

Setting status markers works like this:

!token-mod --set statusmarkers|+blue

December 16 (1 year ago)

Timothy B. said:

I'm trying to use TokenMod to add status markers using animated webm files. It kind of works, but instead of placing the file over the token, it replaces it. It also doesn't loop the animation. Is this at all possible?

Custom Status Markers need to be added into sets outside of the game prior to being able to be used in the game. If you are using TokenMod to change a token's image, then it is just replacing the image, not adding a Status Marker.

https://wiki.roll20.net/Token_Markers

December 16 (1 year ago)
keithcurtis
Forum Champion
Marketplace Creator
API Scripter

Also, I do not think that .webm is a usable format for Token Markers. AFAIK, it's PNG at 512px only.

December 16 (1 year ago)

Yes, thank everyone. My mistake was trying to figure this all out at 5am, I kinda got caught up playing with api scripts all night. You are correct, I was using the token image replacement rather than the token marker code.

In my haste I was under the impression that it was completely bypassing existing token markers and using images instead, which if that were possible would probably allow me to use a webm file. I failed to realize it was using existing token markers.

December 17 (1 year ago)
keithcurtis
Forum Champion
Marketplace Creator
API Scripter

There is a similar script that can attach images to tokens. Look up Token Condition (Also by the Aaron!). It is available through One-Click.

December 18 (1 year ago)


keithcurtis said:

There is a similar script that can attach images to tokens. Look up Token Condition (Also by the Aaron!). It is available through One-Click.


Thanks Keith, you always point me in the right direction. And thanks The Aaron for the mod, that's exactly what I was looking for.

January 02 (1 year ago)

Edited January 02 (1 year ago)

Hi all,

I have a macro for the D&D 5E spell Enlarge Reduce, for the D&D 5E OGL sheet by Roll20. It's all working except that it Enlarges and Reduces both the source and target tokens when it should just be the target token. Debug output shows that the correct token_id or character_id, I tried both, are being used.

I'm probably missing something obvious...

!Scriptcard {{ 

  --#sourceToken|@{selected|token_id}
  --#targetToken|@{target|token_id}
  --#bodyfontface|Helvetica
  --#oddrowfontcolor|#290000
  --#evenrowfontcolor|#290000
  --#bodyfontsize|12px
  --#titlecardbackgroundcolor|#930c10
  --#titlecardbackgroundcolor|#672223
  --#titlefontcolor|#fffebd
  --#titlefontsize|1.5em
  --#titlefontshadow|0
  --#oddrowbackground|#f7ce65
  --#evenrowbackground|#f7ce65
  --#oddrowbackground|#b3ab96
  --#evenrowbackground|#b3ab96
  --#subtitlefontcolor|#fffebd
  --#tablebgcolor|#fffebd
  --#Debug|1
  --#lineheight|10pt
  --#buttonfontsize|10px
  --#buttonbackground|#930c10
  --#buttonbackground|#672223
  --#buttonbackground|rgba(103,34,35,1); display:inline-block;
  --#buttonfontface|Tahoma
  --#buttonpadding|8px
  --#bodyfontface|Helvetica
  --#bodyfontsize|14px
  --#Title|Enlarge Reduce
  --#leftsub|1 Action
  --#rightsub|Duration: 1 minute
  --#emoteText|[*S:character_name] Casts Enlarge Reduce.
  --&Description|You cause a creature or an object you can see within range to grow larger or smaller for the duration. Choose either a creature or an object that is neither worn nor carried. If the target is unwilling, it can make a Constitution saving throw. On a success, the spell has no effect.%br%If the target is a creature, everything it is wearing and carrying changes size with it. Any item dropped by an affected creature returns to normal size at once.%br%Enlarge. The target’s size doubles in all dimensions, and its weight is multiplied by eight. This growth increases its size by one category—from Medium to Large, for example. If there isn’t enough room for the target to double its size, the creature or object attains the maximum possible size in the space available. Until the spell ends, the target also has advantage on Strength checks and Strength saving throws. The target’s weapons also grow to match its new size. While these weapons are enlarged, the target’s attacks with them deal 1d4 extra damage.%br%Reduce. The target’s size is halved in all dimensions, and its weight is reduced to one-eighth of normal. This reduction decreases its size by one category—from Medium to Small, for example. Until the spell ends, the target also has disadvantage on Strength checks and Strength saving throws. The target’s weapons also shrink to match its new size. While these weapons are reduced, the target’s attacks with them deal 1d4 less damage (this can’t reduce the damage below 1).
  -->WhatSpellSlot|
  -->OutputText|
--X|

  --:OutputText|
    --+|[rbutton]Show Description::OutputDescription[/rbutton]
  --X|

  --:OutputDescription|
    --+|[f11][&Description][/f]
  --X|

  --:WhatSize|
    --+Enlarge or Reduce Target?|[br][rbutton]Enlarge::Size;2[/rbutton][rbutton]Reduce::Size;.5[/rbutton]
  --X|

  --:Size|
    --=EorR|[&reentryval]
    --@forselected|token-mod _ignore_selected _ids @{target|character_id} _set scale|*[$EorR]
  --<|

  --:WhatSpellSlot|
    --+At what level is the spell being cast?|
    --+|[rbutton]1::WhatLVL;1[/rbutton][rbutton]2::WhatLVL;2[/rbutton][rbutton]3::WhatLVL;3[/rbutton][rbutton]4::WhatLVL;4[/rbutton][rbutton]5::WhatLVL;5[/rbutton][rbutton]6::WhatLVL;6[/rbutton][rbutton]7::WhatLVL;7[/rbutton][rbutton]8::WhatLVL;8[/rbutton][rbutton]9::WhatLVL;9[/rbutton]
  --X|

  --:WhatLVL|
    --=SlotLevel|[&reentryval]
    --=SlotsTotal|0
    --=SlotsExpended|[*S:lvl[$SlotLevel]_slots_expended]
    --?[$SlotsExpended.Raw] -eq [$SlotsTotal.Raw]|[
	-->NoSlotsLeft|
	--]|[
    --?[$SlotLevel] -eq 0|NoSlot
    --=SlotsLeft|[$SlotsExpended] - 1
	--!a:[*S:character_id]|lvl[$SlotLevel]_slots_expended:[$SlotsLeft]
    --+|Level [$SlotLevel] Slots Left: [$SlotsLeft]
    -->WhatSize|
  --X|
  --:NoSlot|
  --X|

  --:NoSlotsLeft|
  --+|[*S:character_name] has no level [$SlotLevel.Total] spell slots available.
  --X|NoSlotsLeftStop

}}
January 02 (1 year ago)
keithcurtis
Forum Champion
Marketplace Creator
API Scripter

Is there a token mod command in that macro?

Keith, there is a token-mod call in there. In this part here:

--:Size|
    --=EorR|[&reentryval]
    --@forselected|token-mod _ignore_selected _ids @{target|character_id} _set scale|*[$EorR]
  --<|

Timothy, if you are sending in the ids you shouldn't need the @forselected with token-mod

--@token-mod|_ignore_selected _ids @{target|character_id} _set scale|*[$EorR]

That should work as long as you have it configured that players can use ids, which you can confirm with !token-mod --config

January 02 (1 year ago)
keithcurtis
Forum Champion
Marketplace Creator
API Scripter


Joshua N. said:

Keith, there is a token-mod call in there. In this part here:

--:Size|
    --=EorR|[&reentryval]
    --@forselected|token-mod _ignore_selected _ids @{target|character_id} _set scale|*[$EorR]
  --<|


Thanks, I was searching on "!token-mod", not being familiar with the syntax of putting an API call inside a metascript call inside a ScriptCards macro. :D

January 03 (1 year ago)

Thanks guys.

Weird but _ignore_selected doesn't work, the debug output calling to the api looks like --ignore_selected when it should be --ignore-selected. If I use _ignore-selected it outputs correctly and works. Using SelectManager was me desperately trying to figure it out,

January 03 (1 year ago)
The Aaron
Roll20 Production Team
API Scripter

If you have any calls to @{target|...}, the selected property is not passed to the API. I don't know if that's related, but something to be aware of. 

January 04 (1 year ago)
timmaugh
Pro
API Scripter


Timothy B. said:

Thanks guys.

Weird but _ignore_selected doesn't work, the debug output calling to the api looks like --ignore_selected when it should be --ignore-selected. If I use _ignore-selected it outputs correctly and works. Using SelectManager was me desperately trying to figure it out,

Yeah, a fairly typical way scripters indicate new arguments in their command lines is by a space followed by double hyphens:

!scripthandle --arg1=foo --arg2=tacos

ScriptCards uses this convention, too (every line begins with the double hyphens), so to get around the fact that intended-outbound command lines might have similar argument-demarcation, Kurt built the ability to designate outbound double-hyphens with the underscore.

Since the pattern that ScriptCards looks for is "whitespace-double-hyphen", it only looks to replace the underscore at the beginning of a word (that is, following whitespace). Hopefully that makes sense.

January 10 (1 year ago)

Hello all and apologies if this has been answered already, my searching FU has failed me.  I know from reading there may/may not be a bug with this.

I am starting Phandelver with a group of new players to D&D, well rolepalying in general.  I have already got Phandelver and I have created an adventure from the module.


I want to set all the monsters in my game to be:


Bar 1 - Monsters current HP - This is always correct and set right it seems

Bar 2 - Monsters AC - Here lies the problem


Now when I drag a monster onto the board its bar 2 attribute is already set to npc_ac but it doesn't display anything.  If I change it to something else and save then change it back it works.  I then thought, OK I will use !tokenmod to set it after I have dropped so I did:

!tokenmod --sel --set bar2_link|npc_ac

This didn't work.  I thought it may be bacuase it is already set to npc_ac so I did this:

!tokenmod --sel --set bar2_link|ac

!tokenmod --sel --set bar2_link|npc_ac

Nope, no dice.  The only way I worked out to get this to work, which has worked, is to open every monster token bio then close it.  The npc_ac then, without me changing anything, started working.  Now this is not a problem here but I have a couple of other games on the go and I want to change all the tokens to act the same as this.

do I use !chatsetattr -all or has someone come up with a better way

OR

is it a bug that cannot be squashed except with a jumpgate...

January 10 (1 year ago)
The Aaron
Roll20 Production Team
API Scripter

That is really peculiar behavior.  The NPC characters in question here, are they from the module, from the compendium, or created by you?

Do you have the Token Defaults / Character Sheet Defaults set in the Game Settings to use AC in Bar 2?

January 10 (1 year ago)

Edited January 10 (1 year ago)

The Monster tokens are all from the module.

Token defaults are set in the game settings as both empty this time round , though I have tried it with npc_ac in bar 2 as well.  AC gives a different value with monsters I think for some reason and npc_ac I read should be used.


Character sheet defaults are set tothe defaults that the game created.


Don't want to hog this possible "off topic", I do want to use !tokenmod if I can or happy to start a new thread for this.

January 17 (1 year ago)
Josh
Pro

Hi! I am using TokenMod for the first time, and I have a map with torches that change different colors. I have macros set up to do this:

!token-mod --ids -NoKum0PnnHDqL76d8QN --set lightColor#93c47d
!token-mod --ids -NoKvIB8xvr9G9-RLDq4 --set lightColor#ffffff
!token-mod --ids  -NoKvWLwdPJULltWfThs --set lightColor#0000ff
!token-mod --ids -NoKvJWpWFMc3a2lFkA- --set lightColor#ff0000

There are five different macros, with the same format as above, just the colors change. However, I'm finding that sometimes, the colors don't change, or they change to the wrong values. It seems like if I leave the game and re-enter, it fixes itself, but I suspect that when my players are in the game with me, we would all have to leave and re-enter to fix the issue. Is there something I'm doing wrong that can cause this behavior, or is there a way I can force the script to reload while still in the game?


Thanks!

January 17 (1 year ago)
keithcurtis
Forum Champion
Marketplace Creator
API Scripter

Hi Josh!

Some settings are still resistant to updating when done through the VTT. You might be able to force an update by opening the DL settings on the token and then closing them again, which is faster than reloading the entire game.

Hi I have just found Token mod and it is amazing!

I have an issue when trying to expand the tooltip description bar


!token-mod {{
    --set
        tooltip|"aaaaa"
     --on
        show_tooltip
}}


Using this command to expand the tooltip, the formatting of the description is unusable

Is there a way to reformat this command ? as to extend the horizontal axis of the description?


January 19 (1 year ago)
The Aaron
Roll20 Production Team
API Scripter

The visual aspect of the Tooltip is not something the API can change unfortunately. 


The Aaron said:

The visual aspect of the Tooltip is not something the API can change unfortunately. 


Ok thanks!

Hi I have been trying to add NightVision effects Nocturnal

Can you tell me what I am doing wrong?


?{
Light/Vision options:
|DarkVision (Noct60),
!token-mod --on night_vision_effect_nocturnal
}

January 19 (1 year ago)
The Aaron
Roll20 Production Team
API Scripter

The night_vision_effect property is not a simple on/off, you have to set one of the values.  Here's the relevant section from the help:

Night Vision Effect

Night Vision Effect specifies how the region of night vision around a token looks. There are two effects that can be turned on: dimming and nocturnal. You can disable Night Vision Effects using offnone, or leave the field blank. Any other value is ignored.

Available Night Vision Effect Properties:
night_vision_effect

Enable the nocturnal Night Vision Effect on a token:

!token-mod --set night_vision_effect|nocturnal



January 27 (1 year ago)

I recently began using this API's '--move' funciton for fun shenanigans in-game, and it's been working great! I am curious, however, if it is possible for dynamic lighting barriers to restrict this movement. Let me give an example. 

I currently use this for my Tempest Cleric's Thudnerbolt Strike feature: 

@{Goodwin|wtype}&{template:traits} {{name=Thunderbolt Strike}} {{source=Tempest Cleric - 6th Level Feature}} {{description=Goodwin's lightning blasts into **@{target|a Large or smaller creature you dealt lightning damage to|token_name}**, pushing them 10 feet away!}}
!token-mod {{{
--ids @{target|a Large or smaller creature you dealt lightning damage to|token_id}
--move ?{Which direction? (Compass-style)|
North,=0&#124;10ft|
Northeast,=45&#124;14.1ft|
East,=90&#124;10ft|
Southeast,=135&#124;14.1ft|
South,=180&#124;10ft|
Southwest,=225&#124;14.1ft|
West,=270&#124;10ft|
Northwest,=315&#124;14.1ft}
}}}


It functions really well for what I need, but it can push tokens through dynamic lighting barriers if used when a token is near enough to one. Any thoughts?

Thanks in advance. 

January 28 (1 year ago)
The Aaron
Roll20 Production Team
API Scripter
That's something I've intended to add, but haven't gotten around to yet. 
February 15 (1 year ago)

Hello,


Just started getting into scripts and I already love this. The versatility is amazing! My first "project" to do with this is do a simple macro drop down of the statuses so players and myself can easily assign one as needed. I do have a HP script that I modified to indicate health statuses. I wanted to know if there is a way to make the tokenmod ignore specific status(es) that are on the creature token? Currently when I run the "clear all" macro it removes all status including the 5 specific ones that I would like for it to ignore. My current work around is to add hit points then subtract it so that it updates with the HP status again. Any help is appreciated.

February 15 (1 year ago)
The Aaron
Roll20 Production Team
API Scripter

I think you'll have to build an explicit clear all command like:

!token-mod --set statusmarkers|-blue|-red|-green|-happy|-sad

That would leave any of the status not listed on the token unchanged.

February 15 (1 year ago)

Thats what I was afraid of. Thank you for the response tho, I'll just add a line to heal and damage line to get back to their current HP status.

February 20 (1 year ago)

Help Please. Try to use !token-mod --set currentside|2 to change the side of a token. Made a table and label each 1 and 2. Will not change. Copy the token from my market place to my library and recreated the table. Same issue. 

February 20 (1 year ago)
keithcurtis
Forum Champion
Marketplace Creator
API Scripter

Hi Craven!

At this point in time, API scripts cannot affect most Marketplace images. My suggestion would be to download the image(s) and upload it to your own library, and try that for the source.

February 20 (1 year ago)

Edited February 20 (1 year ago)

Hello all,

I have these altitude token markers I bought from the Marketplace.

The markers work with TokenMod.


What I want to do is create a Macro that quickly lets the GM/a player to select a token and an altitude, and apply the relevant marker without needing to create a separate command for each one. In theory, I'd love to be able to set up a [+] and [-] Macro button which increases or decreases the altitude by a step up/down, but I don't think that's within the scope of the API. Instead, just being able to quickly select and apply an altitude marker and replace or remove any existing one would suffice.

I appreciate any assistance.

Thank you.

February 20 (1 year ago)
The Aaron
Roll20 Production Team
API Scripter

Craven, one thing to be aware of is that changing a Rollable Table does not change the Rollable Table Tokens you have already created from it.  If you changed out the images in the table for copies uploaded to your user library, but did not create a new token, the old token will still have the Marketplace images, and thus won't work with the API currently.  Create a new token and it should work with the new User Library images.

February 20 (1 year ago)
The Aaron
Roll20 Production Team
API Scripter

Jeff P.:  Probably that would be easiest to manage with a custom script.  If you want to do it with TokenMod, you could pretty easily with the caveat that it would clear all TokenMarkers when you apply it.  It would look something like:

!token-mod --set statusmarkers|=?{Elevation|None,|5ft,5ft::4706416|10ft,10ft::4706417}


February 20 (1 year ago)


The Aaron said:

Jeff P.:  Probably that would be easiest to manage with a custom script.  If you want to do it with TokenMod, you could pretty easily with the caveat that it would clear all TokenMarkers when you apply it.  It would look something like:

!token-mod --set statusmarkers|=?{Elevation|None,|5ft,5ft::4706416|10ft,10ft::4706417}

That's what I figured, but honestly, the drop-down menu you provided is perfect for my needs! It saves me time from having to select each token and scroll to the bottom of the markers and find the right number each time, which honestly was the main goal.


Thank you!

February 21 (1 year ago)
keithcurtis
Forum Champion
Marketplace Creator
API Scripter


The Aaron said:

Craven, one thing to be aware of is that changing a Rollable Table does not change the Rollable Table Tokens you have already created from it.  If you changed out the images in the table for copies uploaded to your user library, but did not create a new token, the old token will still have the Marketplace images, and thus won't work with the API currently.  Create a new token and it should work with the new User Library images.

Hi Jeff!


If you create the rollable token and set it as the default token for a character sheet you can easily pull that token out over and over again every time you need it, without creating a new one from the Collections tab.

You could even set your elevation macro to be a token action for that character, so the token action button is available whenever you have the elevation token selected.

February 21 (1 year ago)

Edited February 22 (1 year ago)


The Aaron said:

It would look something like:

!token-mod --set statusmarkers|=?{Elevation|None,|5ft,5ft::4706416|10ft,10ft::4706417}

Quick question, when I set to None, the current marker doesn't disappear. I messed around with the code/help/first page of this thread a bit, but I wasn't able to make it work. I appreciate any assistance.

Thank you


EDIT: Nevermind, I figured out a work-around! I appreciate all the help!

February 22 (1 year ago)
The Aaron
Roll20 Production Team
API Scripter

Sorry for the delay, glad you got it working!

Hi, very much enjoying token mod, looking for some help

1)

I am struggling to find anywhere one how to change the bar settings can you direct me to where i can read on that?


2)

This is my current command, I want to change the size and HP for each token can you tell me how to do that?


!token-mod --set currentside|3
!splay Bear roar#2
Krompton Wildshapes into a Bear!

March 04 (1 year ago)
Andrew R.
Pro
Sheet Author

You could use the --scale command to adjust the token size, and the --set bar1_value (or bar2_value or bar3_value) command to adjust the HP depending on which bar is the HP in your game. 

You should tell us what game system, character sheet, and token setup you're using if you need more detailed help. 13th Age setups differ from D&D 5e setups, for example. 

March 04 (1 year ago)
The Aaron
Roll20 Production Team
API Scripter

Some useful options:

  • Size:
    • width -- this sets the width 
    • height -- this sets the height
    • scale -- this sets the width and height both to the same value
      • Follow any of these with a number with units for a specific size, or a mathematical operation and number for a relative adjustment
        • scale|*2 width|70px height|2u
  • Bars:
    • bar1_value -- the current value of bar 1
    • bar1_max -- the max value of bar 1
    • bar1 -- sets the current and max value to the same number
      • follow with a value or a mathematical operation and number for relative changes
        • bar1|65 bar1_current|-30 bar1_max|+20

Here is my current macro for each individual transformation (included simplesound mod and FX)

Is there a way to place all of my transformations into one macro.  A query function?

thanks in advance.


!token-mod {{ --set currentside|3 bar1_value|34| bar1_max|34 bar2_value|-1| bar2_max|2 height|9s| width|9s }}
!splay Bear roar#2
/fx explode-slime
Krompton Wildshapes into a Bear!

April 24 (11 months ago)

Edited April 25 (11 months ago)

Looking for a little assistance. I'm trying to change the AC on a token using the following ScriptCards macro

What I've posted here is just a snippet of the whole code.

  --:Mage-armor|
--+|[c][&SM_Token][/c] --#rightsub|Status
--@act| -1| 4800| _Mage Armor [*[&ThisTarget]:character_name] --delete-le 0
--@token-mod|_set bar3|13+@{selected|dexterity_mod}
--+|[c][b]You touch a willing creature who isn’t wearing armor, and a protective magical force surrounds it until the spell ends.[/c][/b]
--+|[c][b]The target’s base AC becomes 13 + its Dexterity modifier.[/c][/b]
--+|[c][b]The spell ends if the target dons armor or if you dismiss the spell as an action[/c][/b]
--^MARK|

But what happens is the token shows 13+2 instead of just showing 15.




Hey EZ, ScriptCards can do inline math with [= ]. So your --@token-mod line could look like:

--@token-mod|_set bar3|[= 13 + @{selected|dexterity_mod} ]

ScriptCards can even do the object modification itself with `--!t` and using attribute referencing from --#sourceToken it would look like:

--#sourceToken|@{selected|token_id}
--!t:[*S:id]|bar3_value:[= 13 + [*S:dexterity_mod] ]
April 25 (11 months ago)


Joshua N. said:

Hey EZ, ScriptCards can do inline math with [= ]. So your --@token-mod line could look like:

--@token-mod|_set bar3|[= 13 + @{selected|dexterity_mod} ]

ScriptCards can even do the object modification itself with `--!t` and using attribute referencing from --#sourceToken it would look like:

--#sourceToken|@{selected|token_id}
--!t:[*S:id]|bar3_value:[= 13 + [*S:dexterity_mod] ]

Joshua - Thank you, that solved my problem.


June 05 (9 months ago)

This is a current known bug, reported here. I suggest adding your comment there to see if others also have some resolution if they disable TokenMod, and if that's the case then I'm sure TheAaron will start taking a look right away! :) 

You can also file a Help Center Request to get more visibility on the issue.