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

Combining multiple attributes into a single token bar

1538777184

Edited 1538779615
I've searched through the wiki, and maybe I'm not just finding it. I think this is just a syntax problem. Say I've got a big robot with 6 hit locations, and I want to show the general status of its HP on a token bar. My locations have attributes on the character sheet backend, @{StructureHead} @{StructureTorso} etc, manually entered since the system only uses single HP totals and thus only has one HP attribute not six separate ones. Each total has a current and max value, and I'm hoping to combine the six totals together and link that to a single bar on a token. While it may not show that a limb has been blown off, peppering the target with multiple hits that scatter between the locations should diminish the bar enough for the general damage to be evident at a glance. I know this can be done, because some of the D&D sheets combine current HP and temp HP on the same bar, but I'm not figuring out the syntax. EDIT: That might require pro sub for the API, which is over my head at this point. Nothing against upping my sub to pro, but the learning curve made my ears bleed. I tried making a seventh attribute, @{StructureCombined} then had it reference the other six added together, but it doesn't seem to calculate. Of course, I think the necessity of @{Selected|StructureCombined} or @{UnitName|StructureCombined} is likely to interfere with it. Does it require the target's unique name for an attribute to reference another attribute? (I tried variations of that, but haven't guessed the correct syntax) Is there a different way to have a bar on a token call a value other than selecting the attribute from the drop-down? I'm trying to avoid needing the unit's unique name, given that I want this to be a general macro for a range of such robots (PCs are mecha-pilots often fighting other mecha, in a game system that isn't mecha-friendly and thus house-ruled halfway to the moon). Thus far I have a mountain of macros that all rely on @{Selected|X} and @{Target|X} given that I'm literally writing hundreds of macros here, so needing the unit's unique name would make this much more intensive (may not have any choice though).
you need what is called a 'sheet worker' to make the seventh attribute work, I think, as it needs to be a number.  Dont forget you would also need a 'max' attribute, as your token bar needs both the current and max values in order to display.
I was figuring on it being something like [[@{StructureHead}+@{StructureTorso}+...]] for the current and [[@{StructureHead|Max}+@{StructureTorso|Max}+...]] for the maximum, but it appears that the token changes that into [[+++++]] and doesn't do the attribute calls at all. I tried having an attribute called StructureCombined as a shell to calculate the current and max value, but it doesn't pull the numbers at all. I'm starting to think it would require the API for it, because the sheet doesn't actually apply the order of operations until it's called to the chat interface and run through the parser.
1538797682
GiGs
Pro
Sheet Author
API Scripter
token bars and autocalc fields don't really work together that well. I'm pretty sure you arent going to be able to do what you're trying to do without a Pro subscription. With a Pro Subscription, you have two possible approaches: 1) edit the character sheet to create a sheet worker, as Aranador suggests, which can create a dynamic attribute that can be displayed in the token bar. 2) create an API script, which updates attribute values and token bars dynamically. This is good if you dont want to edit the character sheet's structure. Either way would work fine. There is actually a simple approach available for free users. Create a 7th attribute for the total, and whenever you mark damage on one of the hit locations, also manually mark it on the total attribute. That way the bar will update. It's a little clunky, but it's free!
Sad part is that I'm not even a free user, I'm just not a pro user because the extra storage space upgrade from plus to pro hasn't been necessary, and learning JavaScript, CSS, and HTML just to make a few minor tweaks is more effort than I'm willing to put in. I've looked through the wikis for scripting and such on GitHub, how to write character sheets, and so on, and I can't get my head around it at all. At the moment, I already have a scan ability for PCs where they can target an enemy, have it pull a bunch of information into a template, and whisper it to only that PC, so that's ultimately what I'll end up going with. Thanks for confirming that it's something that just isn't possible with the base macro language.
1538932138
Kraynic
Pro
Sheet Author
Make a new attribute named StructureCombined.  In the max section, type in @{StructureHead}+@{StructureTorso}+etc.  Don't make it a roll, since it is a simple calculation.  This will auto fill with the correct max when you set up the token by selecting SI as the attribute the bubble is using.  It won't adjust with damage taken from different places and update as you go, which is a little disappointing because I thought it would until I tested it.  But, you could at least have the max health auto calculated for you if you set up a sheet with that attribute as a base to copy whenever you make new enemy.  I suppose you could also use that formula to fill in the current line instead of just max.  Then it will auto fill that as well and you can manually deduct the current health as you go.