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

Use token-mod to decrement bar value based on prompt

In my Savage Worlds campaign, I use the token bar2_value to identify how many power points a character has.  When a player casts healing, I want to use token-mod to prompt the player for the healing type (Healing costs 3 power points, Greater Healing costs 10 power points). I thought this macro would nail it, but rather than decrementing the bar2_value by -3 or -10, it is changing the value to -3 or -10. What did I mangle here? !token-mod ?{Type|Healing, --set bar2_value#!-3|Greater Healing, --set bar2_value#!-10}
1632723257
GiGs
Pro
Sheet Author
API Scripter
You'll need to grab the old value and apply the -3 or -10 to that value. Also you only need to put the actual duplicated data inside the query, soyour current macro would be: !token-mod --set bar2_value#!?{Type|Healing,-3|Greater Healing,-10} Whar's the ! doing in there? I'm a bit rusty on the syntax but cant remember using that. So I think this should do the trick, if you have the token selected (which i assume you have): !token-mod --set bar2_value#[[@{selected|bar2)-?{Type|Healing,3|Greater Healing,10}]]
1632746384
The Aaron
Roll20 Production Team
API Scripter
The ! Keeps the value bound between 0 and Max. Honestly, what you had should have worked.  I'll try that out and see if there's a bug. 
Well met JP ;-) I didn't realize Roll20 allows the same usernames.  Happy gaming!
Hi, JP 2 ! Thanks GiGs, that got me going. This code worked: !token-mod --set bar2_value#[[@{selected|bar1}-?{Type|Healing,3|Greater Healing,10}]] Appreciate the help!
1632778205
GiGs
Pro
Sheet Author
API Scripter
With Aarons suggestion (thanks for that explanation of ! ), putting an ! before that should stop it from going below 0. Your updated macro takes the valiue from 1, reduces it, and puts it in 2. But if someone runs that macro twice, it will still use the bar1 value, so will end up with the wrong number.
Gah, typo, thanks for the eagle eyes!
1632788488
The Aaron
Roll20 Production Team
API Scripter
JP said: Well met JP ;-) I didn't realize Roll20 allows the same usernames.  Happy gaming! This is actually the reason I put the "The" on my username. I had written a dozen or so scripts and people referred to things as "HoneyBadger's init script" and "Aaron's TurnMarker script" and then another "Aaron" started posting on the forum and I wanted to differentiate between them and me and pictured a fictitious conversation about "who's init script?", "Aaron's.", "Which Aaron?",  "THE Aaron!"  =D
Aaron THE Scriptomancer would work. Just sayin' The Aaron said: JP said: Well met JP ;-) I didn't realize Roll20 allows the same usernames.  Happy gaming! This is actually the reason I put the "The" on my username. I had written a dozen or so scripts and people referred to things as "HoneyBadger's init script" and "Aaron's TurnMarker script" and then another "Aaron" started posting on the forum and I wanted to differentiate between them and me and pictured a fictitious conversation about "who's init script?", "Aaron's.", "Which Aaron?",  "THE Aaron!"  =D
I actually think you do not want to bind the values to above 0, I've discovered that chatsetattr and token mod when you do this, mislead you to think that its always ok to use the ability, they don't tell you that it changed it from 0 to 0.  The only way to know is to have it go negative so the player knows they are out of points.  I do this all the time with spell slots in 5e with chatsetattr, and for tokenmod when I have class and other resources set to bars 2 and 3, theres no error telling me or the player they are out other then the visual that the bar is empty but when I'm not paying attention its hard to catch it.