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

Issue with using "@{selected|character_name}" to update token name

Hello, I have a macro that I'm limping through in which one character transforms into another form temporarily, which I have a token with several actions prepared. My need was to change the image and the represented character to get it to look correct and have the right skills. I can't seem to get it to directly change the image, so my workaround has been to create a different token from a rollable table and then change the face. However, the issue I'm having is then that after changing the represented character, the token label does not change to reflect the name of the new character identity, so I added a line to set that. I did this using --set name|"@{selected|character_name}"                   the quotation marks being there because the character has a space in its name. This actually used to work correctly, but it stopped all of a sudden. I'll test the macro, and it will do everything else except update the token label on the map. Looking at the token settings itself, it can be seen that the character rep and the displayed name have been changed as if the macro functioned correctly, but the physical token is still labeled with the old character's name. It's only after I run the macro again that it actually refreshes the name on the map. I've refreshed my page, exited the site, disabled/re-enabled the token mod macro plugin, you name it. Even weirder is that, if I take the quotation marks out, it functions perfectly fine the first time, but it just applies the first part of the name before the space because there are no ". Any ideas?
1588187261
The Aaron
Roll20 Production Team
API Scripter
The @{ } references are resolved on the client before any commands are issued to the API.  That means if you have a command that both changes the representation and also uses an @{ } reference to change the name, the reference is evaluated before the represents change is made.  You would need to either run this as a second macro (what's causing it to work the second time in your example above) or explicitly address the character's name some how (either by statically typing the name or pulling it from a known token with @{target}, or similar).
Interesting... Thanks for the reply!
1588189929
The Aaron
Roll20 Production Team
API Scripter
There might be some other options if that continues to be a pain point for you.  For example, I could write you a little script that just sets a token's name to it's character's name, which you could call after TokenMod.  Since it would grab the objects in the API at command processing time, rather than chat entry, it would get the correct name.
I hard-coded it, which is clunky, but it works fine for what I need it to do. Don't feel like you have to worry about it! I really appreciate the offer, though! I tried to do that myself before I posted this question, creating a separate macro and calling it after doing the modifications with TokenMod. However, it was called within the large macro, not another, manual call, so I'm not sure if that falls into the same trap.
1588251966
The Aaron
Roll20 Production Team
API Scripter
Yeah, the behavior would be the same. To get the new name, the lookup would need to occur in the API after the change.