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

[Help] Rolltemplate nonempty values not hiding properly

1508279174

Edited 1508290312
Toby
Pro
I am working on some new roll templates for my character sheet and I have run into an issue with {{#<property>}}{{/<property>}} sections not hiding sections correctly.  I am not sure why this isn't working.  I've both empty and non-empty logic and its either all or nothing.. shows or hides regardless of what text I put into the field. Here is the roll template code <rolltemplate class="sheet-rolltemplate-35Adv_CharInfo"><!-- Advanced Character Info --> <div class="sheet-wrapper"> <div class="sheet-border"> <table> <tr><th>{{name}}</th>{{#infolink}}<th class="sheet-info">[i]({{infolink}})</th>{{/infolink}}</tr> <tr><td>{{#gender}}{{gender}}{{/gender}} {{race}} {{#class-0}}{{class-0}} {{level-0}}{{/class-0}} {{#class-1}}/{{class-1}} {{level-1}}{{/class-1}} {{#class-2}}/{{class-2}} {{level-2}}{{/class-2}} {{#class-3}}/{{class-3}} {{level-3}} {{/class-3}} {{#class-4}}/{{class-4}} {{level-4}}{{/class-4}}</tr></td> <tr><td>{{alignment}} {{size}} {{type}} {{subtype}}</td></tr> <tr><td><span class="tcat">Init</span> {{initiative}} {{#senses}}<span class="tcat">Senses</span> {{senses}}, {{/senses}} Perception +{{perception-mod}}</td></tr> <tr><td>--------</td></tr> <tr><td>Defenses</td></tr> <tr><td><span class="tcat">AC: </span> {{ac}}, touch {{touch}}, FF {{ff}}</td></tr> <tr><td>(+{{armor-ac}} armor +{{shield-ac}} shield +{{dex-ac}} dex +{{size-ac}} size +{{dodge-ac}} dodge +{{nat-ac}} nat +{{deflect-ac}} deflect +{{misc-ac}} misc -{{penalty-ac}} penalties)</td></tr> <tr><td><span class="tcat">HP: </span> {{hp}} <span class="tcat">Temp:</span> {{temp-hp}} <span class="tcat">Non-lethal</span> {{nonlethal-hp}} </td></tr> <tr><td><span class="tcat">Fort: </span> +{{fort}} <span class="tcat">Ref: </span> +{{ref}} <span class="tcat">Will: </span> +{{will}}</td></tr> <tr><td><span class="tcat">Fear: </span> +{{fear}} <span class="tcat">Hor: </span> +{{horror}} <span class="tcat">Mad: </span> +{{madness}}</td></tr> <tr><td><span class="tcat">Sit Saves: </span> {{save-notes}}     </td></tr> <tr><td><span class="tcat">Immunities: </span> {{immunities}}     </td></tr> <tr><td><span class="tcat">Weaknesses: </span> {{weaknesses}}     </td></tr> <tr><td>--------</td></tr> <tr><td>Offense</td></tr> <tr><td><span class="tcat">Spd: </span> {{speed}} <span class="tcat">Fly: </span> {{speed}} ({{mnvr}}) <span class="tcat">Swim: </span> {{swim}} <span class="tcat">Climb: </span> {{climb}} <span class="tcat">Burrow: </span> {{burrow}}</td></tr> <tr><td><span class="tcat">Atk Notes: </span> {{atk-notes}}</td></tr> <tr><td><span class="tcat">Melee: </span> {{melee-notes}}</td></tr> <tr><td><span class="tcat">Ranged: </span> {{ranged-notes}}</td></tr> <tr><td><span class="tcat">Special Atks: </span> {{special-atks}}</td></tr> <tr><td>--------</td></tr> <tr><td>Statistics</td></tr> <tr><td> <span class="tcat">APP: </span> {{app-mod}} <span class="tcat">STR: </span> {{str-mod}} <span class="tcat">DEX: </span> {{dex-mod}} <span class="tcat">CON: </span> {{con-mod}} <span class="tcat">INT: </span> {{int-mod}} <span class="tcat">WIS: </span> {{wis-mod}} <span class="tcat">CHA: </span> {{cha-mod}}</td></tr> </table> </div>  </div> </rolltemplate> I'm a bit confused since this has worked on some of my previous roll templates but for some reason is failing to work here.  Any insight or thoughts would be appreciated.
1508289366
Finderski
Pro
Sheet Author
Compendium Curator
Have you checked for typos?
Apart from one I just corrected (an improper closing backet which was causing my sheet not even to load).  Fixed that and it still doesn't function as I expected.
I am confused by your thread title. You want fields to not show when they have a value? If so, is it possible there is a space or other non-visible character in the field that is making it hidden? Can you give more specifics about what is and is not working? Maybe some screenshots, perhaps? I would also recommend stripping the roll template down to one element, testing that until it works, then add a few more, save and test, add a couple more, save and test, etc.
1508295563
vÍnce
Pro
Sheet Author
Is there a specific property/key and value combo that isn't working?  Not sure if this is related, but are you using, or have you tried including the  allprops() helper function?
A screenshot as requested: Note on the line it says Any Red Dragon, it also says 0 / 0 / 0 / 0 / 0.  That has the name of class field, and class level field.  I do not want anything to show if the class name field is blank. At the moment it doesnt matter if I use, Has value or is blank, it either shows everything regardless of having a value, or shows nothing regardless of value. @Vince.  I've honestly never understood the purpose of the allprops().  I mean everything I use is being defined anyway.  And if it wasn't defined, I couldnt use it.  The only thing I can see from the examples it s used in is that it has the generic <<name>> and <<value>>.  And it simply repeats those rows until all properties have been used.  Like a dynamic table.   I mean that could be useful for displaying the weapons, and certainly the spells.  Which is one thing I haven't figured out how to do for my statblock "CharInfo" roll template.   But, one thing at a time.  I have other issues that take priority.
1508300030

Edited 1508300334
vÍnce
Pro
Sheet Author
I think allprops mainly assigns some basic layout/formatting to "all other undefined properties".  So you can include an undefined property/key and value and still have it display properly. I just notice that if you don't include your defined properties in allprops, you get the generic formatting/layout instead of your defined formatting/layout. Check the closing tr and td. I think they are inverted.  <tr><td>{{#gender}}{{gender}}{{/gender}} {{race}} {{#class-0}}{{class-0}} {{level-0}}{{/class-0}} {{#class-1}}/{{class-1}} {{level-1}}{{/class-1}} {{#class-2}}/{{class-2}} {{level-2}}{{/class-2}} {{#class-3}}/{{class-3}} {{level-3}} {{/class-3}} {{#class-4}}/{{class-4}} {{level-4}}{{/class-4}} </tr></td>
The closing tag was indeed inverted, but it seems to have had no effect on the output or layout, and did not fix my issue.  Also, I still dont understand about the allProps().  Are you saying I need to use it, or dont need to use it.
1508304272
vÍnce
Pro
Sheet Author
Toby said: The closing tag was indeed inverted, but it seems to have had no effect on the output or layout, and did not fix my issue.  Also, I still dont understand about the allProps().  Are you saying I need to use it, or dont need to use it. I include allprops() since it allows any undefined {{key=value}} to be included in the macros using that roll template and they still get some basic layout/formatting as I defined within allprops.  Similar to the way roll20's default template works for any {{key=value}} you use.  I don't think it has anything to do with your current issue however. Seems like I recall having a similar problem with "0 0 0 0" showing up when I tried adding optional attributes to include with a roll.  I believe the solution was to set up a hidden attribute that used the defined {{key=value}} as it's value.  Then use that single attribute in the macro.  Something like; <input type="hidden" name="attr_characteristics" value="{{gender=@{gender}}} {{race=@{race}}} {{class-0=@{class-0} @{level-0}}}...etc." disabled> then in your macro just use @{characteristics}
No change. <input type="hidden" name="attr_info-levels" value="{{class-0=@{selected|class-0-name} @{selected|class-0-level} }} {{class-1=@{selected|class-1-name} @{selected|class-1-level} }} {{class-2=@{selected|class-2-name} @{selected|class-2-level} @{selected|class-3-name} @{selected|class-3-level} }} {{class-4=@{selected|class-4-name} @{selected|class-4-level} }}" disabled> With the macro code: &{template:35Adv_CharInfo} &{template:35Adv_CharInfo} {{name=@{selected|token_name}}} {{gender=@{selected|gender}}} {{race=@{selected|race}}} @{selected|info-levels} {{alignment=@{selected|alignment} }} {{size=@{selected|size} }} {{type=@{selected|type}}} {{subtype=@{selected|subtype} }} {{initiative=[[ @{selected|Init} ]] }} {{senses=@{selected|vision} }} {{perception-mod=[[ @{selected|Perception}]] }} {{ac=[[ @{selected|AC} ]] }} {{touch=[[ @{selected|Touch} ]] }} {{ff=[[ @{selected|Flat-Footed} ]] }} {{armor-ac=[[ @{selected|armor-acbonus} ]] }} {{shield-ac=[[ @{selected|shield-acbonus} ]] }} {{dex-ac=[[ @{selected|AC-DEX} ]] }} {{size-ac=[[ @{selected|size} ]] }} {{dodge-ac=[[ @{selected|AC-dodge} ]] }} {{nat-ac=[[ @{selected|AC-natural} ]] }} {{deflect-ac=[[ @{selected|AC-deflect} ]] }} {{misc-ac=[[ @{selected|AC-Misc} ]] }} {{penalty-ac=[[ @{selected|AC-penalty} ]] }} {{hp=@{selected|HP} / [[ @{selected|hp-formula} ]] }} {{temp-hp=@{selected|HP-Temp} }} {{nonlethal-hp=@{selected|non-lethal-damage} }} {{fort=[[ @{selected|Fort} ]] }} {{ref=[[ @{selected|Ref} ]] }} {{will=[[ @{selected|Will} ]] }} {{fear=[[ @{selected|Fear} ]] }} {{horror=[[ @{selected|Horror} ]] }} {{madness=[[ @{selected|Madness} ]] }} {{save-notes=@{selected|Save-notes} }} {{immunities=@{selected|immunities} }} {{weaknesses=@{selected|weaknesses} }} {{speed=@{selected|speed-base} }} {{fly=@{selected|speed-fly} }} {{mnvr=@{selected|fly-maneuverability} }} {{swim=@{selected|speed-swim} }} {{climb=@{selected|speed-climb} }} {{burrow=@{selected|speed-burrow} }} {{atk-notes=@{selected|attack-notes} }} {{app-mod=@{selected|APP-mod} }} {{str-mod=@{selected|STR-mod} }} {{dex-mod=@{selected|DEX-mod} }} {{con-mod=@{selected|CON-mod} }} {{int-mod=@{selected|INT-mod} }} {{wis-mod=@{selected|WIS-mod} }} {{cha-mod=@{selected|CHA-mod} }}
1508317174
Finderski
Pro
Sheet Author
Compendium Curator
So, my assumption is it's displaying that because something is being passed...your macro codes states: {{race=@{selected|race}}} @{selected|info-levels} {{alignment=@{selected|alignment} }} If you never have anything that is level 0, then rather than using: {{#class-1}}{{/class-1}} You could try to check the value, which would require the input value be changed to make each class number be passed as an inline roll for evaluation.  Then your template would need to change to use: {{#rollGreater() class-1 0}}{{class-1}}{{/rollGreater() class-1 0}} And your input field would be something like: <input type="hidden" name="attr_info-levels" value="{{class-0=@{selected|class-0-name} [[d0+@{selected|class-0-level}]] }} {{class-1=@{selected|class-1-name} [[d0+@{selected|class-1-level}]] }} {{class-2=@{selected|class-2-name} [[d0+@{selected|class-2-level}]] @{selected|class-3-name} [[d0+@{selected|class-3-level}]] }} {{class-4=@{selected|class-4-name} [[d0+@{selected|class-4-level}]] }}" disabled> Or, you could change your macro to not include the @{selected|info-levels} bit.
I am not sure how to respond to these, because I'm not sure I;m understanding them.  But, 1) @{selected|info-levels} contains the hidden input value, which from what I understand just short hands everything. 2) {{#class-1}} refers to the TEXT field that is the name of the class, so a rollGreater() wont work.  Furthermore, it was my understanding that one needed to have a roll in the property in order to use #roll functions. 3) I dont at all understand, what would I do if I dont use that @{selected|info-levels}, go back to square one I suppose.  Or are you suggesting I dont include that information at all? In any event, I do appreciate all the assistance that you folks are giving, thank you very much.
1508318589
Jakob
Sheet Author
API Scripter
Here's the problem: in your info-levels variable, you have e.g. {{class-0=@{selected|class-0-name} @{selected|class-0-level} }} Now, if both the class-0-name attribute and the class-0-level attribute are empty (BTW: you should definitely not  use @{selected|...} on the sheet, just use @{class-0-name} and @{class-0-level}!), this will read as {{class-0= }} This means that the class-0 property passed to the roll template is NOT empty, so it will still be displayed! The only way to have the {#class-0} helper function evaluate to false is to either not have class-0 present at all or to have it look like this: {{class-0=}}
I will take a look at it and make those changes, but I have to mention, that this is macro is going to be part of a token selecetion macro.  It will not be directly rolled from the character sheet.  The roll template code will be off of the sheet in the collections.  So, dont I still need the @{selected|...} in that case?
Okay, thank you all for the help. The roll template code I had for the levels was: {{class-0=@{selected|class-0-name} }} {{level-0=@{selected|class-0-level} }} Apparently that space was causing all kinds of problems.  annoying.  Almost 18 hours of dealing with this one issue.