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

[Help] ChatSetAttr

Hello, I am trying to update some attributes on my player character sheets to use the following blind roll macro (I have the blind roll API installed and it functions properly with this command in the attribute): !broll 1d20+@{history_bonus} for History. I can do this just fine by opening up each sheet and pasting this in the attribute I need for each attribute, but was hoping to be able to use ChatSettAttr to do this as a command; as such I tried the following command to no avail: !setattr --sel --history_roll|!broll 1d20+@{history_bonus} for History. But I get the following error:  TypeError: Cannot read properties of undefined (reading 'substring' I tried adding parenthesis, quotes, etc but couldn't manage to find a way to get it to accept my command.  Anyone know a way to get it to replace what I am looking to replace in the roll fields without having to do it manually? Thanks!
1648680931

Edited 1648681264
Oosh
Sheet Author
API Scripter
You will need to escape your @{history_bonus} reference - Roll20 is attempting to evaluate it immediately, and failing because you have no character sheet reference in front of it. Try this: !setattr --sel --history_roll|!broll 1d20+@{history_bonus} for History. You probably only need the @ escaped to @ , haven't used CSA for a long time though so unsure. CSA also supports backslash escaping for some characters - you can try \@\{history_bonus}, but I'm not sure it'll work. Explanation - the Roll20 chat parser is attempting to resolve the attribute reference as soon as you hit enter. Because it's an API chat command, and not running from the context of a character sheet, the parser has no idea which sheet to look at to find the history_bonus attribute and throws an error. Escaping the control characters bypasses the first round of attribute parsing, but the parser will do a round of unescaping - so the @commat; is resolved into a @ , but not until after the parser has had a crack at looking up any @{attribute} references it can find. This should mean the string "!broll 1d20+@{history_bonus} for History." gets stored in the target attribute. You may or may not need an extra level of escaping, which would be @ for an @ symbol
Yep this worked! Thanks so much