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

May 18 (6 years ago)
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?
May 18 (6 years ago)
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.
May 18 (6 years ago)

Edited May 18 (6 years ago)
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.
May 18 (6 years ago)
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 ]]
May 18 (6 years ago)

Edited May 18 (6 years ago)
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?
May 18 (6 years ago)
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.
May 18 (6 years ago)
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.
May 18 (6 years ago)
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Aaron can answer better, but I think --ignore selected takes care of that.
May 19 (6 years ago)
The Aaron
Pro
API Scripter
Yeah. The benefit of an API expression would be applying across multiple tokens. 
May 19 (6 years ago)
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.