
Is there a way to have chatsetattr stop reducing values below 0?
Does your macro rely in decrementing? Or calculations that result in a number that then gets applied/used in the ChatSetAttr call?
Here's an inline solution using MathOps, demonstrating decrementing an arrows value and stopping at 0:
{& math max(0, @{Archelena|arrows} - 1) }
Or, using Fetch, too, you can supply a default value for the attribute if it doesn't exist:
{& math max(0, @(Archelena.arrows[0]) - 1) }
What does a typical macro look like where ChatSetAttr tries to reduce a value below 0?
Yep, so someone may be able to come along and tell you more about a built-in limiter for ChatSetAttr, but until then I think you can do basically what I mentioned, above, provided the -1 is a trigger to CSA to decrement, and we can skip that by just supplying a value.
Grab MathOps, SelectManager, and ZeroFrame and get them installed. If you want to default a value in as a starting point if the attribute isn't found, grab Fetch, too. (I know ChatSetAttr creates and sets the attribute if it doesn't exist; but we need it sooner than that. Using an @{selected} call will stop your macro before it even gets there... but Fetch with a default value will let you proceed.)
!setattr --sel --arrows|{&math max(0,@{selected|arrows}-1)}
Here's the alternate version using the Fetch construction instead of the Roll20 @{selected...}...
!setattr --sel --arrows|{&math max(0,@(selected.arrows[0])-1)}
{&0 fetch math}