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

Roll Template Evaluation: Execution from Sheet vs Execution from Macro Bar.

1543596704

Edited 1543596734
Davemania
KS Backer
Sheet Author
API Scripter
A little more background in this thread . I put together a roll template to display an ability usage tracker, but only if the attribute is greater than 0. It works the way I want it to when I push the roll button from the character sheet. However, when I drag it to the macro bar and execute it from there, it doesn't display when it should, I guess because it is evaluating differently. Shouldn't the results be identical regardless of where it is executed from? <div class="sheet-col-1-2 sheet-padr"> <h4 class="sheet-center">Features</h4> <div class="sheet-row sheet-sub-header"> <div class="sheet-col-2-7 sheet-center sheet-small-label">Feature Name / Uses</div> <div class="sheet-col-5-7 sheet-center sheet-small-label">Feature Description</div> </div> <fieldset class="repeating_features">     <div class="sheet-row">                         <div class="sheet-col-2-7">                             <div class="sheet-row">                                 <input type="text" name="attr_featurename">                             </div>                             <div class="sheet-row">                                 <div class="sheet-col-1-4">                                     <button type="roll" name="roll_Feature" value="&{template:5eDefault} {{feature=1}} {{featuresubheader=@{character_name}}} {{featureuses=@{feature_uses}}} {{featureusesmax=@{feature_uses_max}}} {{featureusesmaxnum=[[@{feature_uses_max}]]}} {{title=@{featurename}}} {{featureshowdesc=@{featuredescr}}}"></button>                                 </div>                                 <div class="sheet-col-3-10">                                     <input type="number" name="attr_feature_uses" min="0" step="1" value="0" />                                 </div>                                 <div class="sheet-col-1-10 sheet-tiny-note">                                      /                                  </div>                                 <div class="sheet-col-3-10">                                     <input type="number" name="attr_feature_uses_max" min="0" step="1" value="0" />                                 </div>                             </div>                         </div>                         <div class="sheet-col-5-7">                             <div class="sheet-auto-expand">                             <span name="attr_featuredescr"></span>                             <textarea class="sheet-auto-expand" spellcheck="false" name="attr_featuredescr"></textarea>                             </div>                         </div>                     </div>                 </fieldset> </div> {{#featuresubheader}}     {{#rollGreater() featureusesmaxnum 0}}         <div class="sheet-rt-subheader">{{featuresubheader}} • {{featureuses}}/{{featureusesmax}} Uses</div>     {{/rollGreater() featureusesmaxnum 0}}     {{#^rollGreater() featureusesmaxnum 0}}         <div class="sheet-rt-subheader">{{featuresubheader}}</div>     {{/^rollGreater() featureusesmaxnum 0}} {{/featuresubheader}} Thanks for your time and attention!
1543598049
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Do you have an attribute not in a repeating section that is also named feature_uses_max? This will cause different evaluation depending on how you call the roll.
1543600704
Davemania
KS Backer
Sheet Author
API Scripter
Scott C. said: Do you have an attribute not in a repeating section that is also named feature_uses_max? This will cause different evaluation depending on how you call the roll. Nope, that is the only attribute with that name on the sheet. I will point out that in order to get the evaluation to work when executed from the sheet, I had to pass the attribute in an inline roll and check against that. Before I did that it also always failed to evaluate as greater than zero. Having done that though, I still can't figure out why the behavior is different from the macro bar.
1543604590

Edited 1543604616
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Hmm, looking at your code again made me realize a mistake I had been making in one of my new roll templates for the Starfinder sheet. Not sure why this would cause a difference between launching from the sheet and launching from the macro bar, but in order to properly evaluate a roll, there typically has to be an actual roll inside the inline roll. So [[1]] usually won't be evaluated correctly whereas [[1d1]] always will. Not sure if this has changed and it just hasn't been documented, or what, but I'd try swapping {{featureusesmaxnum=[[@{feature_uses_max}]]}} for {{featureusesmaxnum=[[@{feature_uses_max}d1]]}}
1543607247
Davemania
KS Backer
Sheet Author
API Scripter
Scott C. said: Hmm, looking at your code again made me realize a mistake I had been making in one of my new roll templates for the Starfinder sheet. Not sure why this would cause a difference between launching from the sheet and launching from the macro bar, but in order to properly evaluate a roll, there typically has to be an actual roll inside the inline roll. So [[1]] usually won't be evaluated correctly whereas [[1d1]] always will. Not sure if this has changed and it just hasn't been documented, or what, but I'd try swapping {{featureusesmaxnum=[[@{feature_uses_max}]]}} for {{featureusesmaxnum=[[@{feature_uses_max}d1]]}} Huh; thanks for the tip. Unfortunately, this made no difference in the behavior of either button. For kicks I also tried {{featureusesmaxnum=[[[[@{feature_uses_max}]]d1]]}} but it made no difference either.
1543940975
Davemania
KS Backer
Sheet Author
API Scripter
Any other eyes on this? Is this a bug?
1543951589

Edited 1543951669
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Hi Dave, I was taking another look at your code and realized what your problem is. Attribute maxes are named "attribute_name_max" in the html, and calling them like that from within the repeating section works fine, but the actual syntax to call an attribute's maximum value is @{characterName|attribute_name|max}. You need to include the character's name or character id in the call in order to call the maximum value of an attribute. You'll need to use a sheetworker to update the character name/id part of this call to match the character, and to do that you'll need to store the macro in a separate attribute so that the sheetworker can modify it.
1543953447
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Hi Davemania, This is a known issue with the current implementation of roll buttons. It is on the devs' radar, but there is no current timeline for implementing a change. Hopefully Scott's workaround will see you through.
1544021991
Davemania
KS Backer
Sheet Author
API Scripter
Thank you very much gentlemen, that explains it. I will look into using a sheetworker to build the roll template in order to use the different syntax for attribute|max within the repeating section.