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 complex roll template as a macro

Hello. 800+ hours in Roll20, I think this is my first post. I am trying to trigger a Roll Template from the Mythras character sheet as an Ability Macro. I have gotten simpler ones to work in the past, but this character sheet seems to save some values not as Attributes, so I do not know how to call them in the Roll Template. The original code for the Roll Template is here on line 2675: <a href="https://github.com/Roll20/roll20-character-sheets/blob/master/Mythras/Mythras.min.html" rel="nofollow">https://github.com/Roll20/roll20-character-sheets/blob/master/Mythras/Mythras.min.html</a> It is the name="roll_combatstyle" section. My goal is to have an Ability Macro which I can use to select a token and trigger that Roll Template, so I do not have to open the character sheet each time. The proper outcome of the Roll Template is this combat summary. I have copied and pasted the chat output as a Macro, but some things like the skill number are "hardcoded" as a value that is not an Attribute. So I can get variables like the weapon buttons to vary based on the selected token, but there are parts that are buried in the Roll Template that I do not know how to trigger. Any help would be appreciated. :-)
1744635814
timmaugh
Pro
API Scripter
So... here is the relevant line from the sheet: @{roll_display}&amp;{template:skill} {{character=@{character_name}}} {{combatstyle=1}} {{weapon_buttons=@{weapon_buttons}}} {{character_id=@{character_id}}} {{name=@{name}}} {{roll=[[1d100]]}} {{fatigue_skills=[[@{fatigue_skills}]]}} {{encumbered=[[@{encumbered}]]}} {{encumbrance_skills=[[@{encumbrance_skills}]]}} {{original=@{total}}} {{difficulty=[[@{difficulty}]]}} {{augmentation=[[@{augmentation}]]}} {{penalty=[[@{penalty}]]}} {{very_easy=[[((@{total}+@{augmentation})*2)+@{penalty}]]}} {{very_easy_crit=[[ceil(((@{total}*2)+@{penalty})/10)]]}} {{very_easy_fumble=[[((@{total}*2)+@{penalty})]]}} {{easy=[[ceil((@{total}+@{augmentation})*1.5)+@{penalty}]]}} {{easy_crit=[[ceil(((@{total}*1.5)+@{penalty})/10)]]}} {{easy_fumble=[[ceil((@{total}*1.5)+@{penalty})]]}} {{standard=[[@{total}+@{augmentation}+@{penalty}]]}} {{standard_crit=[[ceil((@{total}+@{penalty})/10)]]}} {{standard_fumble=[[(@{total}+@{penalty})]]}} {{hard=[[ceil((@{total}+@{augmentation})*.67)+@{penalty}]]}} {{hard_crit=[[ceil(((@{total}*.67)+@{penalty})/10)]]}} {{hard_fumble=[[ceil((@{total}*.67)+@{penalty})]]}} {{formidable=[[ceil((@{total}+@{augmentation})*.5)+@{penalty}]]}} {{formidable_crit=[[ceil(((@{total}*.5)+@{penalty})/10)]]}} {{formidable_fumble=[[ceil((@{total}*.5)+@{penalty})]]}} {{herculean=[[ceil((@{total}+@{augmentation})*@{herculean_mod})+@{penalty}]]}} {{herculean_crit=[[ceil(((@{total}*@{herculean_mod})+@{penalty})/10)]]}} {{herculean_fumble=[[ceil((@{total}*@{herculean_mod})+@{penalty})]]}} {{notes=@{notes}}} All of these character references (like @{penalty}) should resolve as long as this originates on the character sheet — these are shorthand references that assume the character you are referring to is the character where this command launched from. If you put this into an ability on the character, does it not work?
It works from within the character sheet. When I use “selected token” (I am on my phone, don’t have access to the right syntax) as an ability macro then it does not work. The goal is to trigger that roll template from outside of the character sheet, imagine a GM with 6 opponents and wanting to trigger their combat rolls from the map.&nbsp;
1744637343
timmaugh
Pro
API Scripter
OK... I think what you mean by "ability macro" is really a "Collection Tab macro"... because if you put this text into an ability on a character sheet, it will resolve for that character... it will even resolve if you mark it as "Show as Token Action", select the token, and then click the button. Given your stated desire to trigger this for multiple/different opponents, I think what you're lacking is the ability to "agnosticize" this command. In that case, you just have to add "selected|" within each reference... and then potentially replacing the "roll_display" for that character (because that would probably be controlling whether it was whispered, or not; I would suggest explicitly making this whisper to the GM). All of that would look like: /w gm &amp;{template:skill} {{character=@{selected|character_name}}} {{combatstyle=1}} {{weapon_buttons=@{selected|weapon_buttons}}} {{character_id=@{selected|character_id}}} {{name=@{selected|name}}} {{roll=[[1d100]]}} {{fatigue_skills=[[@{selected|fatigue_skills}]]}} {{encumbered=[[@{selected|encumbered}]]}} {{encumbrance_skills=[[@{selected|encumbrance_skills}]]}} {{original=@{selected|total}}} {{difficulty=[[@{selected|difficulty}]]}} {{augmentation=[[@{selected|augmentation}]]}} {{penalty=[[@{selected|penalty}]]}} {{very_easy=[[((@{selected|total}+@{selected|augmentation})*2)+@{selected|penalty}]]}} {{very_easy_crit=[[ceil(((@{selected|total}*2)+@{selected|penalty})/10)]]}} {{very_easy_fumble=[[((@{selected|total}*2)+@{selected|penalty})]]}} {{easy=[[ceil((@{selected|total}+@{selected|augmentation})*1.5)+@{selected|penalty}]]}} {{easy_crit=[[ceil(((@{selected|total}*1.5)+@{selected|penalty})/10)]]}} {{easy_fumble=[[ceil((@{selected|total}*1.5)+@{selected|penalty})]]}} {{standard=[[@{selected|total}+@{selected|augmentation}+@{selected|penalty}]]}} {{standard_crit=[[ceil((@{selected|total}+@{selected|penalty})/10)]]}} {{standard_fumble=[[(@{selected|total}+@{selected|penalty})]]}} {{hard=[[ceil((@{selected|total}+@{selected|augmentation})*.67)+@{selected|penalty}]]}} {{hard_crit=[[ceil(((@{selected|total}*.67)+@{selected|penalty})/10)]]}} {{hard_fumble=[[ceil((@{selected|total}*.67)+@{selected|penalty})]]}} {{formidable=[[ceil((@{selected|total}+@{selected|augmentation})*.5)+@{selected|penalty}]]}} {{formidable_crit=[[ceil(((@{selected|total}*.5)+@{selected|penalty})/10)]]}} {{formidable_fumble=[[ceil((@{selected|total}*.5)+@{selected|penalty})]]}} {{herculean=[[ceil((@{selected|total}+@{selected|augmentation})*@{selected|herculean_mod})+@{selected|penalty}]]}} {{herculean_crit=[[ceil(((@{selected|total}*@{selected|herculean_mod})+@{selected|penalty})/10)]]}} {{herculean_fumble=[[ceil((@{selected|total}*@{selected|herculean_mod})+@{selected|penalty})]]}} {{notes=@{selected|notes}}} See if that works.
Thank you for trying. No, that results in the following error. I think the reason that is that some of the values in the roll template are not linked to Attributes. For example, "total" is not an Attribute listed on the character tokens. This is the core issue I am having. No attribute was found for @{selected|name} No attribute was found for @{selected|encumbered} No attribute was found for @{selected|total} ... repeated many times ... No attribute was found for @{selected|total} SyntaxError: Expected "(", ".", "[", "abs(", "ceil(", "d", "floor(", "round(", "t", "{", [ |\t], [+|\-] or [0-9] but "s" found.
1744723586
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
If all you are wanting is to make a token action for that specific character to output the combat style info for a given row, then you can just call the button itself: %{selected|repeating_combatstyle_$0_combatstyle} Replace the 0 with the row index for the row you want to reference (first row is 0, 2nd is 1, etc)
1744729097
timmaugh
Pro
API Scripter
Scott and I were just having a discussion about this. I didn't understand that this was referencing sub-attributes of a repeating list, which is why my initial suggestion hadn't worked for you. But after talking with Scott, we arrived at 2 different approaches: the one he just outlined, and another I'll share in a minute. The one he just outlined requires no scripts, and is a single button click to run the command. The downside is that either the row entries for this list have to come in the same order for every character, or you have to know where this entry exists for the character you are selecting as a token on the board. Either way, you'd probably have a $0 button, a $1 button, a $2 button, etc... and you have to know which one to click for this particular token. But once you know that, you get the effect immediately off of that one button. The alternate solution *will* use scripts (specifically, the MetascriptToolbox), and it will require a 2-step process... but it is both character- and row-order-agnostic. In fact, it could even be extended to be list- and command- agnostic with a query... but let's not get ahead of ourselves. Here is what the alternate solution would look like... The approach will be to use a metascript to return the row number of the entry in the "combatstyle" list you are interested in, then use that value to construct a chat button with the appropriate reference. There are a lot of moving parts to explain, but the result is fairly simple. Here's an example from the 2014 character sheet. This sheet has a repeating section called "attack" (comparable to the *first* "combatstyle" in the button nomenclature Scott used, above). One of the sub-attributes of this section (that is, one of the fields that help compose all of the information that makes up an entry on the list) is called "atkname." The sub-attribute which outputs the template (analogous to the second "combatstyle" in what Scott wrote) is called "attack". So, to create a button for the $0 row (e.g., the first entry in the list), we'd typically do something like this: /w gm [Your Label Here](~selected|repeating_attack_$0_attack) So what if the entry we wanted to find on this list wasn't always going to be at position $0, but it WAS always going to contain the word "Bread"? This is where the metascripts can help. We can get the row number of the entry on this list for the selected character where the atkname sub-attribute contains the word "Bread" like this: *(selected.attack.[atkname~Bread].atkname.row$) If one character has this "Bread" attack in the first slot, this will return "$0". If another character has the same attack in the second slot, it will return "$1". Knowing we can get this value, we can use this to whisper a button to the GM which will reference the correct slot for the selected character: !/w gm [Label](~selected|repeating_attack_*(selected.attack.[atkname~Bread].atkname.row$)_attack) {&amp;simple} That would be your macro command... so here is the 2 step (2-click) process: run your macro to produce a chat button whispered to you click the chat button to run the appropriate entry from the list on the character Here is the effect in that 2014 sheet: If the same "Bread Loaf (Thrown)" attack existed in a different location on a different character, this command and this 2-step process would still work, and you wouldn't need to remember that for this character it's in slot $0, but for THAT character it's slot $2. TL;DR Solution Now, I'm not familiar with the sheet you're using, nor do I know the criteria whereby you would identify which entry on the list you need to run for the token, so you will have to alter this command to fit your needs. I am going to assume, as a starting place, that you can reference a sub-attribute called "name" where you will look for an entry that contains the word "Main". Replace these as necessary: !/w gm [Your Label Here](~selected| repeating_combatstyle_ *(selected.combatstyle.[name~Main].name.row$) _combatstyle) {&amp;simple} Help Available If you have trouble identifying the sub-attributes available to you to reference, I'd suggest my Inspector script. Basically, select the token, run: !inspect --Character Name Here New Panel (if there are tokens named this in addition to the character): Click on the entry in the list that is for the character. New Panel: Click on the button at the bottom for repeating lists New Panel: Click the button for the "combatstyle" list NewPanel: Click one entry in the list New Panel: The next panel should show you the individual sub-attributes for that entry on that list. Post back if you want to go this route but have trouble with any of this.
1744729379
timmaugh
Pro
API Scripter
Just realized we can simplify that, too. The "name$" construction will return the name of the attribute in $0-notation. So we should be able to have a command line that referenced the sub-attribute "name" where it equals our criteria of "containing the word 'Main'", but then return the name of the "combatstyle" button. That would be: !/w gm [Your Label Here](~selected| *(selected.combatstyle.[name~Main].combatstyle.name$) ) {&amp;simple} You can see how much shorter that is.
1744803997

Edited 1744804113
This solution quoted below worked, thank you. I used fixed combat skills (melee, parry, ranged) and now I have three buttons that will trigger these skills for the selected token. Scott C. said: If all you are wanting is to make a token action for that specific character to output the combat style info for a given row, then you can just call the button itself: %{selected|repeating_combatstyle_$0_combatstyle} Replace the 0 with the row index for the row you want to reference (first row is 0, 2nd is 1, etc) I could not get the other suggested solutions working easily, but thanks for all of the other options.