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 .
×

Custom character sheet : Button Roll losing context in macro

1577592161

Edited 1577592224
Hello, I'm attempting to create a custom character sheet. This character sheet includes a repeating section for skills. Each skill include a roll button that uses character's attributes. When I do click on the roll button from the CharacterSheet skill entry, everything works well. But if I attempt to create a macro from it, attributes does not link correctly anymore. <fieldset class="repeating_skills">         <div class="sheet-slot-skill">             <div class="sheet-skill-header"/>             <br>             <div class="col">                 <input class="sheet-name" type="text" name="attr_SkillName" value="Nouvelle Compétence"/>         </div>         <br><br>             <div class="4colrow" align="center">                 <div class="col">                     <label class="sheet-slot-line">Xp : <input type="number" name="attr_SkillXp"/></label>             </div>                          <div class="col">                     <label class="sheet-slot-line">Maitrise : <input type="number" name="attr_SkillMaster"/></label>             </div>                          <div class="col">                     <label class="sheet-slot-line">Puissance : <input type="number" name="attr_SkillPower"/></label>             </div>         </div>                      <textarea class="sheet-description" type="text" name="attr_SkillDescription">Description de la compétence.</textarea>                      <div class="col">                 <button type="roll" name="attr_SkillRoll" value="                     **@{character_name} :**  *@{SkillName}*                         - **Attribute** : @{SkillAttribute}                         - **Mastering** : @{SkillMaster}                         - **Power** : @{SkillPower}                         - **Difficulty** : ?{Difficulty}                         - **Result** : [[ [[ 1D10!! ]] - [[ (( 1D2 - 1 ) * 1D10!! ) ]] + @{SkillAttribute} + @{SkillMaster} - ?{Difficulty} ]]">                 </button>                 <select name="attr_SkillAttribute" title="Attribus associé">                 <option value="@{Strength}">Strength</option>                 <option value="@{Dexterity}">Dexterity</option>                 <option value="@{Intelligence}">Intelligence</option>                 <option value="@{Charisma}">Charisma</option>                 <option value="@{Constitution}">Constitution</option>         </div>         </div>     </fieldset> Linking button to a macro using @{repeating_skills_0_SkillRoll} gives a wrong output : Claire Louis :   Nouvelle Compétence -  Attribute  : 8 -  Mastering  : -   Power   : -  Difficulty  : 15 -  Result  :  -2 As you can see, Mastering and Power has been lost there. Using button from character sheet works as expected and output the following : Claire Louis :   Leadership -  Attribute  : 12 -  Mastering  : 9 -  Power  : 0 -   Difficulty   : 15 -  Result  :  7
1577594651
GiGs
Pro
Sheet Author
API Scripter
Where are you running the macro from? If it's not on the character sheet, or on the Abilities section of a character sheet, the macro has no way of knowing which  character is being referenced. So if you are running it as a universal macro, you need some way to identify which character to draw the attributes from. You can do this in three ways:  @{selected|repeating_skills_0_SkillRoll}   @{target|repeating_skills_0_SkillRoll}   @{Bilbo|repeating_skills_0_SkillRoll}  The last one means you use the character's actual name. This example is for a character named Bilbo. For the other two: selected  requires a token to be already selected, and it will draw the attributes from the character linked to that token. target  will give you a popup to select a token.
Hello @Gigs, thanks for your answer. I create the macro directly in the character sheet under Abilities section, see image bellow : The character looks linked correctly as the - Attribute is correct, but it seems like the repeating section itself is lost as - Mastering and - Power are lost.
1577597650
GiGs
Pro
Sheet Author
API Scripter
oh! you are using the wrong syntax for a repeating section. It should be @{repeating_skills_$0_Mastering} if you want the first row. Replace $0 with $1 for the second row, $2 for the third row, and so on. Frankly I'm not sure why the SkillAttribute, Difficulty, or Result are working. If they are referring to attributes within the fieldset, they hsouldnt/ Do you have attributes of the same name outside the fieldset? By the way, you can use the default rolltemplate for prettier output: Replace <button type="roll" name="attr_SkillRoll" value="                     **@{character_name} :**  *@{SkillName}*                         - **Attribute** : @{SkillAttribute}                         - **Mastering** : @{SkillMaster}                         - **Power** : @{SkillPower}                         - **Difficulty** : ?{Difficulty}                         - **Result** : [[ [[ 1D10!! ]] - [[ (( 1D2 - 1 ) * 1D10!! ) ]] + @{SkillAttribute} + @{SkillMaster} - ?{Difficulty} ]]">                 </button> with <button type="roll" name="attr_SkillRoll" value="&{template:default} {{name=**@{character_name} :**  *@{SkillName}*}} {{**Attribute**=@{SkillAttribute}}} {{**Mastering** = @{SkillMaster}}}{{**Power** = @{SkillPower}}}{{**Difficulty** = ?{Difficulty}}} {{**Result** = [[ [[ 1D10!! ]] - [[ (( 1D2 - 1 ) * 1D10!! ) ]] + @{SkillAttribute} + @{SkillMaster} - ?{Difficulty} ]]}}"></button> It's a single line so hard to read here, but copy and paste it all and try it out.
1577602300
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
I'll add on to GiGs' great post, that you're also using the wrong syntax to create a button and therefore to call a button. Button names should start with "roll_" instead of "attr_" and you then call them using the ability reference, e.g.: %{repeating_skills_$0_skillroll}
Thanks, the $ did the trick very well ! Is this the result expected with your code snippet ? SkillAttribute is refering to the option bellow the button, each one of theses options links to a character sheet attribute, but is selected as drop down menu in the skill windows. Difficulty is entered in a popup each time we call the roll. And result is just the final calculation :)
1577605193

Edited 1577605290
GiGs
Pro
Sheet Author
API Scripter
No, it shouldnt look like that. That indicates some formatting error, like a linebreak. It hink its probably the colon in the name part. Looks like I had a couple of errors in there: Power and Difficulty should start with {{ not {, like the other entries. I'm not sure that's enough to explain the error. Make sure there are no line breaks in the button value - everything between the quotes must be a single line. If you havent added linebreaks, maybe its something else. For testing purpose, try changing this {{name=**@{character_name} :**  *@{SkillName}*}} to {{name=@{character_name} -- @{SkillName}}} This is just to check if the colon or asterisks are interfering - i dont think they should, but it's possible.
1577605212
GiGs
Pro
Sheet Author
API Scripter
Scott C. said: I'll add on to GiGs' great post, that you're also using the wrong syntax to create a button and therefore to call a button. Button names should start with "roll_" instead of "attr_" and you then call them using the ability reference, e.g.: %{repeating_skills_$0_skillroll} well spotted!
1577606074

Edited 1577606091
Ha thanks, moving it to single line did the trick again. I guess @Scott C. comment is more of a naming convention ? Working very well now, thanks :)
1577606606
GiGs
Pro
Sheet Author
API Scripter
Draad said: Ha thanks, moving it to single line did the trick again. I guess @Scott C. comment is more of a naming convention ? Working very well now, thanks :) Great! No, its not just a naming convention. If it;s name starts with roll, you can reference it the way Scott described in other macros, or for creating clickable buttons in chat, often as part of a Chat Menu , or for dragging to your macro bar at the bottom of the screen (if you have it enabled). None of these will work unless its name starts with roll_. 
1577610019

Edited 1577610243
Attempting to rename the button like advised : <button type="roll" name="roll_SkillRoll" value="&{template:default} {{name=@{character_name} : @{SkillName}}} {{Attribute=@{SkillAttribute}}} {{Mastering=@{SkillMaster}}} {{Power=@{SkillPower}}} {{Difficulty=?{Difficulty}}} {{Result= [[ [[ 1D10!! ]] - [[ (( 1D2 - 1 ) * 1D10!! ) ]] + @{SkillAttribute} + @{SkillMaster} - ?{Difficulty} ]]}}"></button> And calling it from same place with %{repeating_skills_$0_SkillRoll} is producing an error instead of the previous output TypeError: Cannot read property 'substring' of undefined
1577613939
GiGs
Pro
Sheet Author
API Scripter
I always forget that calling Abilities like this always need a character identifier (their name, selected, or target), even when in the Ability section of the character sheet. If you have put it in an ability, just add the character's name to the start, like %{SOMEONE|repeating_skills_$0_SkillRoll}
1577650865

Edited 1577650920
Ha yeah, working well now, thanks both of you for your kind help and advices :) I used it this way  %{selected|repeating_skills_$0_SkillRoll} I hope to master my first game on roll20 by 4 january, can't wait to test the system with my players ˆˆ
1577651932
GiGs
Pro
Sheet Author
API Scripter
Good luck!