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

Codin advantage/disadvantage/normal

Hi everyone ! I'm currently struggling with coding advantage/disadvantage/normal for my character sheet... I'm here so far:  <div class="thead"><button type="roll" class="bcar" name="FOR" title="Jet de Force" value="&{template:tmpl} {{pc=@{character_name}}} {{name=Force (FOR)}} {{roll= ?{Avantage?|Avantage,2d100kl1|Normal,1d100|Desavantage,2d100kh1}} {{target=[[@{COM}+(?{Bonus(+)/Malus(-)|0})[Bonus/Malus]]]}}" |>FOR</button></div> But it's not working at all and when I press the "FOR" button to roll my dice, I have a choice between advantage/disadvantage/normal but then I choose one of them and nothing happend... Could you help me with that ? :)
1589970358

Edited 1589971119
GiGs
Pro
Sheet Author
API Scripter
button names need to begin with roll_ , so that should be name="roll_FOR"  That's probably not your issue though. You can - and really should - test button values in chat when they aren;t working properly. So createa character, add an Ability to the Attributes and Abilities tab, and enter this is the text: &{template:tmpl} {{pc=@{character_name}}} {{name=Force (FOR)}} {{roll= ?{Avantage?|Avantage,2d100kl1|Normal,1d100|Desavantage,2d100kh1}} {{target=[[@{COM}+(?{Bonus(+)/Malus(-)|0})[Bonus/Malus]]]}} Then play around with that text to get it working. Once it is working, copy it into the character sheet. You can go further and take out every section inside the {{ }} after the =, and test them individually in chat. So for roll you can test ?{Avantage?|Avantage,2d100kl1|Normal,1d100|Desavantage,2d100kh1} and for target, you can test [[@{COM}+(?{Bonus(+)/Malus(-)|0})[Bonus/Malus]]] That last one includes an attribute (@{COM}) so for testing, you'd need to change that to include selected or a character name, like so [[@{selected|COM}+(?{Bonus(+)/Malus(-)|0})[Bonus/Malus]]] Having done all this and looking it over, it looks to me like this part is your issue {{roll= ?{Avantage?|Avantage,2d100kl1|Normal,1d100|Desavantage,2d100kh1}} It should be {{roll= [[?{Avantage?|Avantage,2d100kl1|Normal,1d100|Desavantage,2d100kh1} ]] }} You're missing one } at the end, and the roll should probably be in inline roll brackets. Do this kind of testing, and you can find problems with rolls fairly quickly.
It's working ! Thank you a lot, you're a king ;)
1589982094
GiGs
Pro
Sheet Author
API Scripter
youre welcome :)
I have a second question, if you don't mind, I'm trying to create Auto-calculating value like dodge or damage bonus. So far: <div class="mycol colfin">                 <div class="coltitre fin">Esquive</div>                 <div class="inps">                     <label>ESQUIVE</label>                     <input type="number" name="attr_esquive">                     <label>Mod</label>                     <input type="number" name="attr_esquive_Mod" value="0" readonly>                 </div>             </div> And I created, as you said in an other post, a sheetworker method. So I had this at the top of my html file: <script type="text/worker">     on("change:esquive sheet:opened", function () {  // stat names need to be lower case here         getAttrs(["esquive"], function(values) {  // this step grabs the value of the stat             let base = parseInt(values.esquive)||0; // we store the stat in a variable so we can manipulate it. parseInt makes sure it is recognised as a number and not text.             let mod = 0; //you could change this to mod = "___"; if you want a number output for 0. But you cant use the mod in macros then, so its not a good idea.             if (base > 90) mod = 30;             if (base < 90 AND base > 69) mod = 20;             if (base < 70 AND base > 49) mod = 10;             if (base < 50 AND base > 29) mod = 0;             if (base < 30 AND base > 9) mod = -10;             if (base < 10) mod = -20;                     setAttrs({                 "esquive_Mod": mod // save the modifier to the Strength_Mod attribute.             });         });     }); </script> But I have nothing so far...
and actually, it's not a "mod", it's based on agility and follow this table: Normal 0 21 false false false FR X-NONE X-NONE /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Tableau Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-parent:""; mso-padding-alt:0cm 5.4pt 0cm 5.4pt; mso-para-margin-top:0cm; mso-para-margin-right:0cm; mso-para-margin-bottom:8.0pt; mso-para-margin-left:0cm; line-height:107%; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri",sans-serif; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi; mso-fareast-language:EN-US;} 100-90 30 80-70 20 60-50 10 40-30 0 20-10 -10 0 -20
1589986198
GiGs
Pro
Sheet Author
API Scripter
The problem seems to be in these lines             if (base < 90 AND base > 69) mod = 20; if (base < 70 AND base > 49) mod = 10; if (base < 50 AND base > 29) mod = 0; if (base < 30 AND base > 9) mod = -10; In javascript, use && in place of AND, like so             if (base < 90 && base > 69) mod = 20;             if (base < 70 && base > 49) mod = 10;             if (base < 50 && base > 29) mod = 0;             if (base < 30 && base > 9) mod = -10;             Though since you have a very regular pattern here, you could do away with the entire if statement: let mod = Math.round(base/20) * 10 -20;