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

Referencing Generic Token Bars

I'm curious if I can, and if so how. By Bars I mean the three circles and their corresponding meters that all tokens can be set with. I wanted to set one of them to be the creature's Basic Attack Bonus so I can ref that with a one click weapon macro. So is it possible? Or do I have to link it to a default character representing the creature type itself?
1481258863
Lithl
Pro
Sheet Author
API Scripter
Sure you can. You can treat the bars as attributes named "bar1", "bar2", and "bar3" when using the @{selected|...} or @{target|...} syntax. The token doesn't have to be representing a character. So, for example: @{selected|bar1} / @{selected|bar1|max} ([[round(@{selected|bar1} / @{selected|bar1|max} * 100)]]%) would display something like 12 / 75 (16%) .
Honestly didn't think it would be that simple, thanks! :)
1481285734
Lithl
Pro
Sheet Author
API Scripter
You can also use @{selected|token_name} if you're looking to make generic macros for tokens not representing characters. =)
1481318521
Andrew C
Marketplace Creator
Oh, and also remember that Bars can take all sorts of text, including macro text if you REALLY want to get ambitious.
@{target|token_name} has @{target|bar3} / @{target|bar3|max} ([[round((@{target|bar3}/@{target|bar3|max})*100)]]%) Remaining! ^gives me the folowing errors: No attribute was found for @{TARGET:bar3|max} No attribute was found for @{TARGET:bar3|max} SyntaxError: Expected "[" but "A" found. Did I mess it up?
1481408547
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Using the target keyword has a special syntax when referencing the max value of an attribute:&nbsp;<a href="https://wiki.roll20.net/Macros#Advanced_Usage" rel="nofollow">https://wiki.roll20.net/Macros#Advanced_Usage</a>
ahh, awesome, thanks
1481409792
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Your welcome, happy rolling; it's been fun bouncing between threads with you ;)
@Brian So just for fun I plugged in your little example marco and tried it and got a rather large and confusing error: SyntaxError: Expected "(", ".", "[", "abs(", "ceil(", "d", "floor(", "round(", "t", "{", [ |\t], [+|\-] or [0-9] but "/" found. So what exactly does this point to as the problem?
1481478008
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Do you have anything in the bars? if not, then it would probably give that error. I think that it is messing up in this way: @{selected|bar1} / @{selected|bar1|max} ([[round( @{selected|bar1} / @{selected|bar1|max} * 100)]]%) The bolded area needs bar1 and its max to resolve to a number. If bar1 is empty then the equation resolves to this: &nbsp;/ &nbsp;([[round( &nbsp;/ &nbsp; * 100)]]%) The round function needs numbers to act on, and here the first non space character it finds is a slash, which is not valid unless it is part of a numerical expression (e.g. 5/4).
Ah that's it! I keep forgetting the Bars are 3, 2, 1 left to right not 1, 2, 3, that always trips me up, it works fine with the correct bar in place of bar 1.
1481481156
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
They're actually 3, 1, 2 left to right.
Indeed they are, still really frustrating. Tell me is there mayhap a good reason why the Roll20 Devs decided to do it that way? Or was it just a simple oversight?
1481487731
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
No idea, but I do agree.
1481494297
Lithl
Pro
Sheet Author
API Scripter
Jake W. said: Indeed they are, still really frustrating. Tell me is there mayhap a good reason why the Roll20 Devs decided to do it that way? Or was it just a simple oversight? The bar order is designed for players. For example, if the GM only has bar 1 visible, it's centered for the player's view. If only bars 1 & 2 are visible, the order is 1, 2 and it's right-aligned. It's only weird if you can see all three bars.