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 .
×
May your rolls be merry + bright! 🎄
Create a free account

Referring a macro to a dynamic attribute

1684534870

Edited 1684536766
Apologies if this has already been asked. I am unsure about the correct terminology, and my searches yield no results. Many character sheets use "dynamic" attributes (or fields) for things such as equipment, abilities, weapons etc. With dynamic I mean that rows can be added and removed . This means that each field does not have a dedicated attribute, as I understand it. See example from the Old School Essential sheet below. I am current running Knave, and the character sheet has "static" fields only (not possible to add/remove rows). Since each field has a pre-defined unique attribute, it allows me to run a macro where I select a weapon through a dropdown, and the script handles the rest. There is no need to open the character sheet when a simple bandit or goblin makes an attack. See screenshot below; On to my question : is there a way to reproduce the solution I use in Knave, and implement it for character sheets with dynamic attributes? Is it even possible to refer a macro to a dynamic attribute? I'll include the Knave scripts below for the sake of clarity. Many thanks in advance for any advice or suggestions. Without HTML entity replacements &{template:default} {{name=⚔️ Attack | @{selected|token_name}}}?{Weapon|@{selected|attack_1_desc},{{Weapon=@{selected|attack_1_desc}}}{{Type=⚔️ Melee (STR)}}{Weapon=@{selected|attack_1_desc}}}{{Attack=[[1d20+[[@{selected|strength}-10+@{selected|melee_bonus1}]]]] ([[1d20+[[@{selected|strength}-10+@{selected|melee_bonus1}]]]]) vs **AC**}}{{Damage=[[@{selected|attack_1_damage}]]}}| @{selected|attack_2_desc},{{Weapon=@{selected|attack_2_desc}}}{{Type=⚔️ Melee (STR)}}{Weapon=@{selected|attack_2_desc}}}{{Attack=[[1d20+[[@{selected|strength}-10+@{selected|melee_bonus2}]]]] ([[1d20+[[@{selected|strength}-10+@{selected|melee_bonus2}]]]]) vs **AC**}}{{Damage=[[@{selected|attack_2_damage}]]}}| @{selected|attack_3_desc},{{Weapon=@{selected|attack_3_desc}}}{{Type=⚔️ Melee (STR)}}{Weapon=@{selected|attack_3_desc}}}{{Attack=[[1d20+[[@{selected|strength}-10+@{selected|melee_bonus3}]]]] ([[1d20+[[@{selected|strength}-10+@{selected|melee_bonus3}]]]])vs **AC**}}{{Damage=[[@{selected|attack_3_damage}]]}}| @{selected|attack_4_desc},{{Weapon=@{selected|attack_4_desc}}}{{Type= Ranged (WIS)}}{Weapon=@{selected|attack_4_desc}}}{{Attack=[[1d20+[[@{selected|wisdom}-10+@{selected|ranged_bonus4}]]]] ([[1d20+[[@{selected|wisdom}-10+@{selected|ranged_bonus4}]]]]) vs **AC**}}{{Damage=[[@{selected|attack_4_damage}]]}}| @{selected|attack_5_desc},{{Weapon=@{selected|attack_5_desc}}}{{Type= Ranged (WIS)}}{Weapon=@{selected|attack_5_desc}}}{{Attack=[[1d20+[[@{selected|wisdom}-10+@{selected|ranged_bonus5}]]]] ([[1d20+[[@{selected|wisdom}-10+@{selected|ranged_bonus5}]]]]) vs **AC**}}{{Damage=[[@{selected|attack_5_damage}]]}}} With HTML entity replacements &{template:default} {{name=⚔️ @{selected|token_name} | Attack}}?{Weapon|@{selected|attack_1_desc},{{Weapon=@{selected|attack_1_desc}}}{{Type=⚔️ Melee (STR)}}{Weapon=@{selected|attack_1_desc}}}{{Attack=[[1d20+[[@{selected|strength}-10+@{selected|melee_bonus1}]]]] ([[1d20+[[@{selected|strength}-10+@{selected|melee_bonus1}]]]]) vs **AC**}}{{Damage=[[@{selected|attack_1_damage}]]}}| @{selected|attack_2_desc},{{Weapon=@{selected|attack_2_desc}}}{{Type=⚔️ Melee (STR)}}{Weapon=@{selected|attack_2_desc}}}{{Attack=[[1d20+[[@{selected|strength}-10+@{selected|melee_bonus2}]]]] ([[1d20+[[@{selected|strength}-10+@{selected|melee_bonus2}]]]]) vs **AC**}}{{Damage=[[@{selected|attack_2_damage}]]}}| @{selected|attack_3_desc},{{Weapon=@{selected|attack_3_desc}}}{{Type=⚔️ Melee (STR)}}{Weapon=@{selected|attack_3_desc}}}{{Attack=[[1d20+[[@{selected|strength}-10+@{selected|melee_bonus3}]]]] ([[1d20+[[@{selected|strength}-10+@{selected|melee_bonus3}]]]])vs **AC**}}{{Damage=[[@{selected|attack_3_damage}]]}}| @{selected|attack_4_desc},{{Weapon=@{selected|attack_4_desc}}}{{Type= Ranged (WIS)}}{Weapon=@{selected|attack_4_desc}}}{{Attack=[[1d20+[[@{selected|wisdom}-10+@{selected|ranged_bonus4}]]]] ([[1d20+[[@{selected|wisdom}-10+@{selected|ranged_bonus4}]]]]) vs **AC**}}{{Damage=[[@{selected|attack_4_damage}]]}}| @{selected|attack_5_desc},{{Weapon=@{selected|attack_5_desc}}}{{Type= Ranged (WIS)}}{Weapon=@{selected|attack_5_desc}}}{{Attack=[[1d20+[[@{selected|wisdom}-10+@{selected|ranged_bonus5}]]]] ([[1d20+[[@{selected|wisdom}-10+@{selected|ranged_bonus5}]]]]) vs **AC**}}{{Damage=[[@{selected|attack_5_damage}]]}}}
Those dynamic attributes are what's known as Repeating Attributes . They can be referenced in similar fashion to other attributes and their names are formed from four parts "repeating_" - All repeating attributes start like this Section name - This is specific to the sheet, could be things like "items_" or "attacks_" Row Index or Id - This identifies the line "$0_" would be the first line, "$1_" the second or an ID "-KC0zCLum1Rq3V5wssyE_" for a specific line attribute name - This is specific to the sheet and identifies the attribute you want to reference from amongst the ones for that line
1684548401
GiGs
Pro
Sheet Author
API Scripter
Note that RainbowEncoder's solution might produce unpreductable results if you move the order within a section, or you try to to click a button for an attribute that doesn't exist. If you have access to the sheet code, you can add a series of buttons that automatically have the right values. Since youre a pro subscriber, you can also use a script solution, like Universal Chat Menus , which (with a bit of finagling) will create a chat menu buttons for only those abilities which actually exist.
1684551885
timmaugh
Forum Champion
API Scripter
Also, you could use Fetch (a metascript) to get the appropriate entry in the repeating list by feeding known information. Repeating attributes have a rowID which links many individual attributes which act like cells on that row...so every row might have a Name, Damage, and Description field (among others). So for a list named "Inventory", the first entry might have a rowID of -M1234567890abcdefg. That means that the sub-attributes that would be a part of that row entry would have names like: repeating_inventory_-M1234567890abcdefg_name repeating_inventory_-M1234567890abcdefg_damage repeating_inventory_-M1234567890abcdefg_description Alternatively, you can replace that rowID with a shorthand index in the form $0, $1, etc, to refer to the position it is displayed on the character sheet... that's why GiGs warned about the possibility that the entry that used to be found at $0 (which you built your macro around) is now at $4, and what is *actually* at $0 is something completely different. Using the rowID form, above, would not be affected by moving the entry around in the list. However, it's a pain to find the rowID. It's an even bigger pain to try to read the rowID version, later, to remember which entry on the this that particular ID referred to. That's where Fetch can help: *(Character Name.Inventory.[name = 'Jazz Hands'].damage) That would get the damage attribute from the list item that had a name attribute that equaled "Jazz Hands". Combined with ZeroFrame, you can output the same template look to chat, but have dynamic references to the repeating attributes.
Thank you everyone for your suggestions, and for pointing me to the correct terminology. I haven't had time to test your ideas yet, but I'll post an update when I have tested your suggestions. The intended user scenario is for the GM to use the menu for monsters and goons. so I think the likelihood of a repeating attribute index change is small, but should be avoided nonetheless. I'm trying to make the solution dynamic, by showing all available "weapons" or "attacks" . It might be one attack, it might be 5. If I can use them all without opening up the character sheet, it's a win. If I can use one universal macro that uses the token, rather than individual macros for the ~100 or so enemies in my library, it's perfect.  I've dabbled a bit with customizing existing character sheets, but even if I just use the HTML and CSS exactly as provided on the GitHub the character sheets always look strange and wrong, with unintended linebreaks and such. So far it hasn't been worth the headache. Once again, thanks!