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

Quick Token-Mod API Question

1526651188
Andrew C
Marketplace Creator
The Aaron, or anyone else, is there a way in a basic macro to stop the Token-Mod API from dropping a Bar_Value below zero? i.e. If Bar1_Value = 5, and you send !token-mod --sel bar1_value|-10 to the same token, can you prevent it from causing Bar1_value = -5?
1526651873
The Aaron
Pro
API Scripter
You'd do that with the kh1 modifier: !token-mod --set bar1_value|[[ { [[@{selected|bar1}-10]],0}kh1 ]] I haven't added a way to do that in the API, but probably could.  Let me know.
1526652712

Edited 1526652798
Andrew C
Marketplace Creator
I have used this !token-mod --set bar1_value| [[ { (@{selected|bar1}+(?{HP Change|0}) ), 0}kh1 ]] but it seems to fill the value with a Text Null since I can't edit it through the macro again. Instead I have to edit the token bar directly. I can't for instance use the macro on the same token and include 5 or +5.
1526653869
The Aaron
Pro
API Scripter
You can't have a space after the |: !token-mod --set bar1_value|[[ { (@{selected|bar1}+(?{HP Change|0}) ), 0}kh1 ]]
1526654079

Edited 1526654113
The Aaron
Pro
API Scripter
So if I were going to add a syntax for bounding the result would it make sense to do something like: !token-mod --set bar1_value|_-10 !token-mod --set bar1_value|^+10 !token-mod --set bar1_value|_^+[[1d100-50]] Where _ means bounded to greater than or equal to 0 and ^ means bounded to not more than the max value and _^ means bounded between 0 and the max value?
1526682484
Andrew C
Marketplace Creator
I think you could make it __ for lower limit, _^ for upper limit, and then the expression to be performed after (not sure how you want to tell the parser that we're done setting boundaries) As in: !token-mod --set bar1_value|__-10+[[ expression goes here]] would allow you to do whatever but not go below -10. !token-mod --set bar1_value|_^[[@{selected|bar1|max}]]+[[ expression goes here ]] would allow you to do whatever but not go above the Max value for the bar. !token-mod --set bar1_value|__0_^[[@{selected|bar1|max}]]+[[ expression goes here ]] would restrict the values of Bar 1 to be between 0 and Bar1 Max.
1526683118
Andrew C
Marketplace Creator
Also interesting note on behaviour, if you make a group selection of tokens, it will apparently choose one of them in particular and apply that value to all of them, rather than token-by-token.
1526687284
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Aaron can answer better, but I think --ignore selected takes care of that.
1526694433
The Aaron
Pro
API Scripter
Yeah. The benefit of an API expression would be applying across multiple tokens. 
1526697394
Andrew C
Marketplace Creator
keithcurtis said: Aaron can answer better, but I think --ignore selected takes care of that. I was trying a group selection, just so I could simulate what might happen with a Burning Hands/Fireball/Thunderwave etc.