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

Macros using custom resource fields?

1626126670

Edited 1626126854
I’m new to using macros in Roll20. I wonder if anyone can help with building a macro that pulls data from custom resource boxes. My character has the Healer Feat. Creatures can gain hit points from this feat only once per rest. I use custom resource boxes in my character sheet to track who I have healed with this feat between rests. I want to make a one-click macro that will pull the data from my resource boxes and put it in chat. I’m not looking for automation like ammo tracking or anything to update these fields for me. I’m just looking for a way to quickly and easily share this information with the GM and other players (the GM is constantly asking me if I’ve already bandaged this person or that person since our last rest!). Something like this (currently does not work!): &{template:npcaction} {{rname=Healer Feat}} {{description=*Who can Baetha Bandage?* Baetha: [[@{Baetha|other_resource|Baetha}]] available Beldani: [[@{Baetha|other_resource|Beldani}]] available Donny: [[@{Baetha|other_resource|Donny}]] available Gildas: [[@{Baetha|other_resource|Gildas}]] available Iaculis: [[@{Baetha|other_resource|Iaculis}]] available Zahlia: [[@{Baetha|other_resource|Zahlia}]] available}} My problem is that I can’t seem to discover the correct field names for the resource boxes. The macro shown above returns 1 for all the lines, regardless of what numbers appear in any of my custom resource boxes. I have tried many variations on the field name besides what is shown above, but nothing has worked, and I can’t seem to find any posts about how to pull data from these fields. Who can help? Thanks very much for your time! Miriam
1626134523
GiGs
Pro
Sheet Author
API Scripter
The names you have to use for those is a bit confusing, and has to be grabbed from the sheet HTML. Assuming this is the D&D 5e by  Roll20 sheet, I would recommend not using the top two boxes - keep them free for other things. Assuming you are just using the OTHER RESOURCES boxes, you should be able to access them like: Baetha: [[@{Baetha|repeating_resource_$0_ resource_ left}]] available Beldani: [[@{Baetha| @{repeating_resource_$0_ resource_ left} ]] available Donny: [[@{Baetha| repeating_resource_$1_ resource_ left }]] available Gildas: [[@{Baetha| repeating_resource_$1_ resource_ right }]] available Iaculis: [[@{Baetha| repeating_resource_$2_ resource_ left }]] available Zahlia: [[@{Baetha| repeating_resource_$2_resource_right }]] available The first row left and right boxes are named repeating_resource_$0_ resource_ left repeating_resource_$0_ resource_ left and you increase the $0 number by 1 per row.
Thank you so much for responding, GiGs! Yes, we are using the D&D 5e by Roll20 sheets. The resource boxes I pictured are actually the 4th, 5th, and 6th rows of the Other Resource boxes in my character sheet. I revised my macro as follows based on your suggestions: &{template:npcaction} {{rname=Healer Feat}} {{description=*Who can Baetha Bandage?* Baetha: [[@{Baetha|repeating_resource_$4_resource_left}]] available Beldani: [[@{Baetha|repeating_resource_$4_resource_right}]] available Donny: [[@{Baetha|repeating_resource_$5_resource_left}]] available Gildas: [[@{Baetha|repeating_resource_$5_resource_right}]] available Iaculis: [[@{Baetha|repeating_resource_$6_resource_left}]] available Zahlia: [[@{Baetha|repeating_resource_$6_resource_right}]] available}} But it is returning this error when used: SyntaxError: Expected "(", ".", "[", "abs(", "ceil(", "d", "floor(", "round(", "t", "{", [ |\t], [+|\-] or [0-9] but end of input found. Any thoughts on what this means?
1626219358
GiGs
Pro
Sheet Author
API Scripter
Remember 0 is the first row, 1 is the 2nd row, etc, so you should be using $3 to $5. If you are still getting an era, try your code with just one of the 6 boxes - and go through them one by one to see if each works.
1626219416

Edited 1626219556
Oosh
Sheet Author
API Scripter
edit - ninjad! Also what GiGs said, though in the case of the 5e resource section, the problem is compounded by the fact that the "first" row is not actually part of the repeating section. So once you include the first row (@{class_resource} and @{other_resource}), the second row is $0, third row is $1 and so on. That's an error in an inline roll. It looks like you might have whitespace in one of those fields, which will break the [[ roll ]]. There needs to be some kind of mathematical expression inside. These are fine: [[ 0 ]] [[ 0 + 0 ]] [[ 00000 ]] [[0.0*0]] But these are not: [[ ]] [[ blah ]] [[ + + 11 ]] So you either need to ensure that there's never any garbage in any of those fields, or remove the [[ inline roll ]] from around the @{attribute} call. This is only going to change the formatting, but you could throw a ***@{attribute}*** Roll20 format in there instead.
I retyped it all to make sure there wasn't a typo or bad character or something such, and it is working now! Here is the macro I ended up with. &{template:npcaction} {{rname=Healer Feat}} {{description=*Who can Baetha Bandage?* Baetha: [[@{Baetha|repeating_resource_$3_resource_left}]] available Beldani: [[@{Baetha|repeating_resource_$3_resource_right}]] available Donny: [[@{Baetha|repeating_resource_$4_resource_left}]] available Malistrae: [[@{Baetha|repeating_resource_$4_resource_right}]] available Theo: [[@{Baetha|repeating_resource_$5_resource_left}]] available Zahlia: [[@{Baetha|repeating_resource_$5_resource_right}]] available}} Thanks a bundle for your help! :) Miriam
1626226456
GiGs
Pro
Sheet Author
API Scripter
Great :)