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

Trouble with dice values

So I'm using my very limited skills to make a simple custom sheet by cannibalizing other people's far better work, and I've predictably hit a snag I don't know how to fix. I'm trying to get a die roll with modifiers to display on the sheet, and the die value is being parsed as a number somehow, e.g. 1d12 shows up as 112, 2d12 as 212, and so on. I can't figure out how other sheets have dealt with this issue, even though they obviously have. Any help appreciated.
1515194937
vÍnce
Pro
Sheet Author
You might want to post a small sample of your code to help. Here's an example of a button that rolls a 1d20 + a strength modifier. I'm wrapping this within an inline roll so that it will resolve to a single number in chat.  You could also use "/roll" or "/r" instead of using an inline roll.  Without either, it would just be considered text.  That may be your issue. <button type="roll" name="roll_d20" value="[[ 1d20 + @{STR-mod} ]]">1d20</button>
Here's the code for the actual part that's giving me trouble, specifically the last text input in the button. 'dmgbase' is an earlier text attribute where the die notation goes. It's the weapon damage die, so it's got to be variable. <div class="display"> <button type="roll" name="roll_attack" value="&{template:default} {{name=@{character_name}}} {{Attack with @{atkname}=[[1d20+@{atkbonus}]]}} {{Damage=[[@{dmgbase}+@{dmgatt}+@{dmgmod}]]}}"> <input type="text" name="attr_atkname" style="width: 95px;" value=""> <input type="text" name="attr_atkbonus" style="width: 35px; text-align: center;" value="((@{atkatt}+@{atkmod1}+@{atkmod2}+@{atkmod3}))" disabled="true"> <input type="text" name="attr_atkdmgtype" style="width: 95px;" value="@{dmgbase}+((@{dmgatt}+@{dmgmod}))" disabled="true"> </button> </div> The weird thing is that the button *performs* perfectly, so dmgbase is passed to the roll template as a die roll. I just can't get the button to stop displaying e.g. '117' instead of '1d12+5'.
1515204132

Edited 1515229562
vÍnce
Pro
Sheet Author
I don't think you can nest inputs within a button like that... anything put in between< button> and </button> will probably just be treated as text.   Try separating the button from the inputs. something like this; <div class="display">  <button type="roll" name="roll_attack" value="&{template:default} {{name=@{character_name}}} {{Attack with @{atkname}=[[1d20+@{atkbonus}]]}} {{Damage=[[@{dmgbase}+@{dmgatt}+@{dmgmod}]]}}"></button>  <input type="text" name="attr_atkname" style="width: 95px;" value="">  <input type="text" name="attr_atkbonus" style="width: 35px; text-align: center;" value="((@{atkatt}+@{atkmod1}+@{atkmod2}+@{atkmod3}))" disabled="true">  <input type="text" name="attr_atkdmgtype" style="width: 95px;" value="@{dmgbase}+((@{dmgatt}+@{dmgmod}))" disabled="true">  </div> EDIT: My bad, that's actually a neat trick.
No good. The button has no visibility or functionality, the inputs are displaced, and 1d12 still displays as 112. Being treated as text would be fine, but I've tried putting dmgbase in its own input field for display (with the modifier listed in a separate input), and it still comes through without the 'd', so it's not being passed as the raw text value either.
1515208239

Edited 1515229574
vÍnce
Pro
Sheet Author
"Being treated as text" means that the html would not function as expected, if it's even recognized... EDIT: Actually, that seems to be a cool trick to include everything within the button.  Neat. My snippet of code from above seems to work for me as a simple isolated test. I just made the attributes used manually and assigned them values of "0" for simplicaity. Can you pull values to chat for each of the attributes separately? ie does entering @{selected|dmgbase} or any of the other attributes, post their values as expected in chat? Can you post a screen shot showing how the roll is only showing as text?
Thanks for sticking with me, Vince. Vince said: Can you pull values to chat for each of the attributes separately? ie does entering @{selected|dmgbase} or any of the other attributes, post their values as expected in chat? No, but the button is part of a repeating structure, so it actually has some other non-obvious component to it. None of the attributes of a specific weapon show up in the Attributes & Abilities tab of the character, although the formulae for atkdmgtype and atkbonus do. Pulling those just gets me formulae and not values, though. Here's the code for the whole 'attacks' section of the sheet: <div style="position: relative;"> <span>ATTACKS</span> <div> <span style="width: 95px;">NAME</span> <span style="width: 25px;">ATK</span> <span style="width: 95px;">DAMAGE</span> </div> <fieldset> <div> <input type="checkbox" name="attr_options-flag" checked="checked"><span>y</span> <div> <div> <span>NAME:</span> <input type="text" name="attr_atkname"> </div> <div> <span>ATTACK:</span> <select name="attr_atkatt"> <option value="@{str}" selected="selected">MELEE</option> <option value="@{dex}">RANGED</option> <option value="0">-</option> </select> <span>+</span> <input type="text" name="attr_atkmod1" value="@{lvl}" disabled="true"> <span>+</span> <input type="text" name="attr_atkmod2" placeholder="0"> <span>+</span> <input type="text" name="attr_atkmod3" placeholder="0"> </div> <div> <span>RANGE:</span> <input type="text" name="attr_atkrange" placeholder="Melee" style="width: 170px;"> </div> <div> <span>DAMAGE:</span> <input type="text" name="attr_dmgbase" placeholder="1d6" style="width: 50px;"> <span>+</span> <select name="attr_dmgatt"> <option value="@{str}" selected="selected">STR</option> <option value="0">-</option> </select> <span>+</span> <input type="text" name="attr_dmgmod" default="0"> </div> </div> <div> <button type="roll" name="roll_attack" value="&{template:default} {{name=@{character_name}}} {{Attack with @{atkname}=[[1d20+@{atkbonus}]]}} {{Damage=[[@{dmgbase}+@{dmgatt}+@{dmgmod}]]}}"> <input type="text" name="attr_atkname" style="width: 95px;" value=""> <input type="text" name="attr_atkbonus" style="width: 35px; text-align: center;" value="((@{atkatt}+@{atkmod1}+@{atkmod2}+@{atkmod3}))" disabled="true"> <input type="text" name="attr_dmgdie" style="width: 40px;" value="[[@{dmgbase}]]" disabled="true"> <input type="text" name="attr_atkdmgtype" style="width: 40px;" value="@{dmgbase}+((@{dmgatt}+@{dmgmod}))" disabled="true"> </button> </div> </div> </fieldset> </div> Vince said: Can you post a screen shot showing how the roll is only showing as text? I'm not sure exactly what you mean, so I hope this is what you're asking for: As per the code above, the grey display fields that make up the button show the weapon name, the total attack bonus, the damage die (inaccurate) and the damage die plus modifiers (also inaccurate). (STR is +1 for this character.)
How is the dmgbase attribute created?
1515228677

Edited 1515229892
vÍnce
Pro
Sheet Author
AFAIK, repeating attributes and hidden attributes won't show on the attribute list, so that's normal for those particular attributes to be mia.  looking at the button code from above;         <button type="roll" name="roll_attack" value="&{template:default} {{name=@{character_name}}} {{Attack with @{atkname}=[[1d20+@{atkbonus}]]}} {{Damage=[[@{dmgbase}+@{dmgatt}+@{dmgmod}]]}}">            <input type="text" name="attr_atkname" style="width: 95px;" value="">            <input type="text" name="attr_atkbonus" style="width: 35px; text-align: center;" value="((@{atkatt}+@{atkmod1}+@{atkmod2}+@{atkmod3}))" disabled="true">            <input type="text" name="attr_dmgdie" style="width: 40px;" value="[[@{dmgbase}]]" disabled="true">            <input type="text" name="attr_atkdmgtype" style="width: 40px;" value="@{dmgbase}+((@{dmgatt}+@{dmgmod}))" disabled="true">          </button>  atkbonus - the attribute's used for this value should also include default values.  need to add value="0" to atkmod2 and atkmod3 dmgdie - should probably just show dmgbase.  I would use a span to show a read-only value of dmgbase. ie <span name="attr_dmgbase"></span> atkdmgtype -  remove dmgbase from this value.  It can be seen just before this field.   no css, so it's rather ugly, but this is something I got working.  No clue if it will work with the rest of your code/css.  ;-P So here's a "working" version of the code for me.  fyi: Not sure if it's just missing because of the forums(they often eat code), but I added class="repeating_attacks" to the fieldset.  A class name starting with "repeating_<insert name>" is required on all fieldsets by roll20 to function properly.  Don't use underscores in the repeating name and avoid caps as well.  Adjust the name I used as needed.  bolded my code changes below. Hope this helps <div style="position: relative;">    <span>ATTACKS</span>    <div>      <span style="width: 95px;">NAME</span>      <span style="width: 25px;">ATK</span>      <span style="width: 95px;">DAMAGE</span>    </div>    <fieldset class="repeating_attacks" >      <div>        <input type="checkbox" name="attr_options-flag" checked="checked"><span>y</span>        <div>          <div>            <span>NAME:</span>            <input type="text" name="attr_atkname">          </div>          <div>            <span>ATTACK:</span>            <select name="attr_atkatt">              <option value="@{str}" selected="selected">MELEE</option>              <option value="@{dex}">RANGED</option>              <option value="0">-</option>            </select>            <span>+</span>            <input type="text" name="attr_atkmod1" value="@{lvl}" disabled="true">            <span>+</span>            <input type="text" name="attr_atkmod2" placeholder="0" value="0" >            <span>+</span>            <input type="text" name="attr_atkmod3" placeholder="0" value="0" >          </div>          <div>            <span>RANGE:</span>            <input type="text" name="attr_atkrange" placeholder="Melee" style="width: 170px;">          </div>          <div>            <span>DAMAGE:</span>            <input type="text" name="attr_dmgbase" placeholder="1d6" style="width: 50px;">            <span>+</span>            <select name="attr_dmgatt">              <option value="@{str}" selected="selected">STR</option>              <option value="0">-</option>            </select>            <span>+</span>            <input type="text" name="attr_dmgmod" value="0" default="0">          </div>        </div>        <div>          <button type="roll" name="roll_attack" value="&{template:default} {{name=@{character_name}}} {{Attack with @{atkname}=[[1d20+@{atkbonus}]]}} {{Damage=[[@{dmgbase}+@{dmgatt}+@{dmgmod}]]}}">            <input type="text" name="attr_atkname" style="width: 95px;" value="">           <input type="text" name="attr_atkbonus" style="width: 35px; text-align: center;" value="(@{atkatt}+@{atkmod1}+@{atkmod2}+@{atkmod3})" disabled="true" />            <span name="attr_dmgbase"></span> +           <input type="text" name="attr_atkdmgtype" style="width: 40px;" value=" (@{dmgatt}+@{dmgmod}) " disabled="true" />          </button>        </div>      </div>    </fieldset>  </div>
Well, the field displays the correct value, but it doesn't look great due to something in the styling demanding the span have it's own line. Still, I can work with that. Thanks, man.
Rabulias said: How is the dmgbase attribute created? It's a text input, typed in by whoever.