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

How to target a token Bar in script?

I am trying to modify the text for the ammo tracker API to that it deducts from the selected tokens “Bar 3” but can’t figure what the target name/variable is for “Bar 3”. Tried bar3, bar_3, and a few other guesses. Hoping someone knows offhand?
1507494891
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
The  wiki is your friend when figuring out what to work with. The bars are: bar1_value "" Current value of Bar 1. This may be a number or text. bar2_value "" bar3_value "" bar1_max "" Maximum value of Bar 1. If _value and _max are both set, a bar may be displayed above the token showing the percentage of Bar 1. bar2_max "" bar3_max ""
1507495621
The Aaron
Pro
API Scripter
Are you talking about my Ammo script?  It's really only set up to adjust attributes, which are associated with characters.  Adjusting it to change bars might be more difficult than just associating a bar with an attribute you change. Is what you are trying to accomplish just adjusting bar by some amount?  I'd probably use TokenMod for that: !token-mod --set bar1_value|-1
The Aaron said: Are you talking about my Ammo script?  It's really only set up to adjust attributes, which are associated with characters.  Adjusting it to change bars might be more difficult than just associating a bar with an attribute you change. Is what you are trying to accomplish just adjusting bar by some amount?  I'd probably use TokenMod for that: !token-mod --set bar1_value|-1 Yeah, so your ammo script works great for my players and for unique NPCs. Super helpful! But when I have generic NPCs (such a Stormtrooper, for example) who all have the same stats, share a character sheet, but there are multiple copies of them on the map...I can't use the character sheet as a reference or they will all share one life total, one ammo total, etc. So I was trying to modify the condition to be that when I roll the Stormtroopers attack from the sheet, it reduces the 3rd bar (my ammo bar) for the current token selected. I will try your suggestion there to see if it does the trick!
Scott C. said: The  wiki is your friend when figuring out what to work with. The bars are: bar1_value "" Current value of Bar 1. This may be a number or text. bar2_value "" bar3_value "" bar1_max "" Maximum value of Bar 1. If _value and _max are both set, a bar may be displayed above the token showing the percentage of Bar 1. bar2_max "" bar3_max "" Thank you!!
So it appears this suggestion works. Will get to test it full force when we play the game live. Thanks again for the help!