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

Using the API to display bar values in a bespoke format

I am looking to create tokens that look like this: My first thought is that I can make some Decorations that are from 1 - 10, and drag them on to the tokens as need be. But that's suboptimal, given that we have three bars for each of these tokens and one of them is always the number I'm displaying in the bottom right. The required information is right there in the token. Is it possible via current API to display that number in a different fashion? Barring that, could I link the value to a token with a text box in it and update the text box on the fly?  Maybe there's some `OnBarValueChanged()` event firing somewhere that I could capture and auto apply decorations? 
1612670907
GiGs
Pro
Sheet Author
API Scripter
No, there's no way native to roll20 to change the way the token bars are formatted or presented. You can probably do this with CSS manipulation with an extension like Stylus, but these are entirely client-side - which means it changes the display only for you, not your other players. Everyone who wants the altered display would need to install the extension.
Definitely look into Stylus and the Stylening thread  for some ideas.  Like GiGs mentioned, it'll only affect what you see on your screen, so if you want your players to have the same display they'll have to install the same Stylus code as well.
GiGs, Jarren, thank you for the replies. I will look into that, and I can accept that the bar format and presentation can't be altered. Is there a way for a token to update itself based on a value in a different token? Something like a listening decoration that changes the value in a text box whenever the token it is listening to adjust stats. 
Oh wow, it looks like  on("change:graphic:bar1_value") And similar events might be what I'm looking for. Interesting!