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 .
D&D 2024 has arrived! Pre-Order the new core rulebooks now.
Create a free account

[Help] ChatSetAttr evaluate and attributes with value of 0

So ChatSetAttr lets you set an attribute based on another attribute, referencing the latter attribute with percentage symbols on both sides, like so: !setattr --sel --attr1|%attr2% This sets attr1 to the same value as attr2. The --evaluate command lets you do math using these attributes referenced this way, but this doesn't seem to work when the referenced attribute equals 0 or lower. I was trying to set up a command that will set a skill modifier to the difference between the skill's current value and 10 so that the skill plus the modifier become 10. When the skill's value is 0 or lower, though, I get an error. The command: !setattr --evaluate --sel --acrobatics_temporary|10-%acrobatics% The error when acrobatics = 0: SyntaxError: Unexpected end of input. Attribute acrobatics_temporary left unchanged. The error when acrobatics = -1 or lower: SyntaxError: Invalid left-hand side expression in postfix operation. Attribute acrobatics_temporary left unchanged. This works with characters whose acrobatics value is anything greater than 0. Does anyone know a workaround for this? Any help is greatly appreciated!
What's really throwing me off is I'm able to get this to work with a normal command with a math function (below), but I need to convert it to an --evaluate command so I can have it called by another API. !setattr --sel --acrobatics_temporary|[[10-(@{selected|acrobatics})]] Anyone know why the --evaluate function messes up when zeros and negatives are involved?

Edited 1611139987
I think I've solved it! !setattr --evaluate --sel --acrobatics_temporary|10-(%acrobatics%0/10) This is working whether acrobatics is below -10, between -10 and -1, 0 exactly, between 1 and 10, or greater than 10. Using %acrobatics%/1 didn't work when its value was zero even though it worked with negative numbers, but I guess it handles 00/10 better than 0/1 . So if anyone is having trouble with evaluate and attributes with 0 or negative values, use (%attr%0/10) instead of just %attr% .
Sheet Author
API Scripter
Thats a clever solution.
GiGs said: Thats a clever solution. Thanks! I might have fried my brain a bit trying to figure this one out lol