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

ChatSetAttr and selecting by @{character-name}

I'm using ChatSetAttr (!setattr) from a roll button on a character sheet.  I attempt to select the character using the "built-in" character name like this: !setattr --name @{character-name} {{ . . . but I get this: Errors No character named Breelee Aoceum|character-name found. No target characters. You need to supply one of --all, --allgm, --sel, --allplayers, --charid, or --name. I added "attr_character-name2" to the character sheet and put the name in there exactly as in the Character Journal, and ran the following from the roll button on the character sheet and it worked. !setattr --name @{character-name2} {{ Is there some reason I can't reference the built-in journal name there?  It seems like it "almost" worked.
1524197672
The Aaron
Pro
API Scripter
Try @{character_name}
1524206265
Jakob
Sheet Author
API Scripter
It's not really pertinent to the question, but I would use  --charid @{character_id} which is generally safer to use (two character with the same name, which is admittedly a fringe case).
Ok, thanks!  I was looking for the best way to reference the character in this situation.  How does Roll20 tell the context for @{character_id} or @{character_name}?  If I just typed "--!setattr --charid @{character_id} . . . " into the chat window how would it know which character I'm talking about?  Isn't a roll button on a sheet just putting text into the chat?  How does that have the context?
1524232186
The Aaron
Pro
API Scripter
Commands executed in a character's ability are assumed to be on that character unless explicitly specified.  Everywhere else, you must explicitly specify the character using @{target|...} @{selected|...} @{Some Character Name|...}
1524232468
The Aaron
Pro
API Scripter
Regarding Roll buttons, if you push up in chat, you'll see that it prefaces all the stats with the character's name:
1524242426

Edited 1524242751
I knew about the ability macros assuming the character's attrs unless otherwise stated.  The Roll button is good information.  Interesting that it's handled differently! Also this explains the error output I was seeing!  It prefaced the "@{character-name}" with the character's name, like a roll button does, and then also there was not a "character-name" attribute. No character named Breelee Aoceum|character-name found. The two of you have really helped me understand a lot of things.  I hope I can give back by helping others in the future.
Hey everyone was wondering if anyone had a macro to add a Attribute to sellected tokens?
1527179446

Edited 1527179488
GiGs
Pro
Sheet Author
API Scripter
Anthony V. said: Hey everyone was wondering if anyone had a macro to add a Attribute to sellected tokens? This will add an attribute called NewStat to all selected characters, and set its value to 0: !setattr --sel --NewStat|0 If the stat already exists, it will overwrite it. If it doesn't exist, it will create it.