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 button formula don't work

1766832513
Maïlare
Pro
Sheet Author
API Scripter
Hello, I'm losing hope of getting this formula to work. I have tried some solutions, HTML entities replacements, modify roll template, ask an AI to find a solution but my formula don't work and I have this error in the console when I click on the roll button : vtt.bundle.73258f8 … .js:54127 Uncaught (in promise) d20.DicePEG.result.SyntaxError  { name : 'SyntaxError' , expected : Array(13) , found : null , message : 'Expected "(", ".", "[", "abs(", "ceil(", "d", "flo…, [ |\\t], [+|\\-] or [0-9] but end of input found.' , offset : 0 , … } column : 1 expected : (13)  [ '"("' ,   '"."' ,   '"["' ,   '"abs("' ,   '"ceil("' ,   '"d"' ,   '"floor("' ,   '"round("' ,   '"t"' ,   '"{"' ,   '[ |\\t]' ,   '[+|\\-]' ,   '[0-9]' ] found : null line : 1 message : "Expected \"(\", \".\", \"[\", \"abs(\", \"ceil(\", \"d\", \"floor(\", \"round(\", \"t\", \"{\", [ |\\t], [+|\\-] or [0-9] but end of input found." name : "SyntaxError" offset : 0 [[Prototype]] : Object My roll button is in a repeating section, here the code of the section : <div class="f-row nowrap f-spaceEven" style="margin-bottom: 5px;">                <div class="f-col nowrap f-center"> <button type="roll" class="sheet-d10-dice" style="margin-left:0px;line-height:10px;height:20px;margin-bottom:2px;" name="roll_pcMeleeWeapon" value="&{template:degats} {{perso=@{pcName} }} {{name=@{pcMeleeWeapName} }} {{RollDegats=[[@{pcMeleeWeapDmgDice}d@{pcMeleeWeapDmgDiceType}+@{pcMeleeWeapDmgMod}]] }} {{TotalDegats=[[@{pcMeleeWeapDmgDice}d@{pcMeleeWeapDmgDiceType}+@{pcMeleeWeapDmgMod}+@{pcMeleeWeapEffectDmgMod}]] }} {{effet=@{pcMeleeWeapEffectName} }} {{pourcentage=[[@{pcMeleeWeapEffectPercentage}]] }} {{RollTour=[[1d@{pcMeleeWeapEffectTurnNb}]] }}"></button> </div> <div class="f-col nowrap f-center"> <span class="col-title">Nom</span> <input class="char-textbox" type="text" name="attr_pcMeleeWeapName" style="width: 200px;"/> </div> <div class="f-col nowrap f-center"> <span class="col-title">Dégâts</span>     <div class="f-row nowrap f-center">     <input class="other-textbox-stat" type="number" name="attr_pcMeleeWeapDmgDice"/> <span class="other-textbox-label" style="margin-left: 3px; margin-right: 3px;">d</span> <input class="other-textbox-stat" type="number" name="attr_pcMeleeWeapDmgDiceType" style="width: 40px;"/> <span class="other-textbox-label" style="margin-left: 3px; margin-right: 3px;">+</span> <input class="other-textbox-stat" type="number" name="attr_pcMeleeWeapDmgMod"/> </div> </div> <div class="f-col nowrap f-center"> <span class="col-title">Niveau</span> <input class="other-textbox-stat" type="number" name="attr_pcMeleeWeapLvl"/> </div> <div class="f-col nowrap f-center"> <span class="col-title">Poids</span> <input class="other-textbox-stat" type="number" name="attr_pcMeleeWeapWeight"/> </div> <div class="f-col nowrap f-center"> <span class="col-title">Prix</span> <input class="char-textbox" type="text" name="attr_pcMeleeWeapPrice" style="width: 75px"/> </div> <div class="f-col nowrap f-center"> <span class="col-title">Porté ?</span> <input type="checkbox" name="attr_pcMeleeWeapWear" value="1" checked /> </div> </div> <div class="f-row nowrap f-spaceEven" style="margin-bottom: 5px;"> <div class="f-col nowrap f-center"> <span class="col-title">Effet</span> <select class="char-textbox" name="attr_pcMeleeWeapEffect" style="width:200px;">        <option value="0">-Aucun-</option> <option value="1">Paralysie</option> <option value="2">Empoisonnement</option> <option value="3">Affliction</option> <option value="4">Brulûre</option> <option value="5">Gel</option> <option value="6">Électrocution</option> <option value="7">Banissement</option> </select> <input type="hidden" name="attr_pcMeleeWeapEffectName" value=""/> </div> <div class="f-col nowrap f-center">     <span class="col-title">%</span> <input class="other-textbox-stat" type="number" name="attr_pcMeleeWeapEffectPercentage" default="0"/> </div> <div class="f-col nowrap f-center"> <span class="col-title">Nb tours max</span> <input class="other-textbox-stat" type="number" name="attr_pcMeleeWeapEffectTurnNb"/> </div> <div class="f-col nowrap f-center"> <span class="col-title">Mod dégâts</span> <input class="other-textbox-stat" type="number" name="attr_pcMeleeWeapEffectDmgMod"/> </div> </div> And my roll template code : <rolltemplate class="sheet-rolltemplate-degats"> <div class="rollTmpt-container"> <div class="rollTmpt-header"> {{#perso}} <div class="roll-header-persoTitle">{{perso}}</div> {{/perso}} {{#name}} <div class="roll-header-subtitle">{{name}}</div> {{/name}} </div> <hr align="center" width="50%"> <div class="rollTmpt-content"> {{#effet}} <div class="roll-content-effet">Effet :{{effet}}</div> {{#rollGreater() Roll pourcentage}} <div class="roll-content-effet-success">L'effet ne se déclenche pas.</div> {{#RollDegats}} <div class="roll-content-roll">Dégats :{{RollDegats}}</div> {{/RollDegats}} {{/rollGreater() Roll pourcentage}} {{#rollLessEqual() Roll pourcentage}} <div class="roll-content-effet-fail">L'effet se déclenche !</div> {{#RollTour}} <div class="roll-content-effet-turns">Nombre de tours :{{RollTour}}</div> {{/RollTour}} {{#TotalDegats}} <div class="roll-content-roll">Dégats :{{TotalDegats}}</div> {{/TotalDegats}} {{/rollLessEqual() Roll pourcentage}} {{/effet}} </div> </div> </rolltemplate> Thanks if someone see my error.  
1766851583
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
The only issue I see is that  there is no reason to have the html replacements for the ending bracket of an attribute call, and in fact, this is probably causing at least part of the error as the r20 system winds up looking for an attribute named "pcName} ". This could then cause an issue because it can't find the correct attribute, and because it eats the ending bracket of the roll template field, it also screws up the roll template display if you did get it to roll without the error. Beyond that, all I can suggest is simplifying the button's output until you narrow down what part of the output is causing the issue.
1766853918
vÍnce
Pro
Sheet Author
Not sure if it has any bearing with your error, but Is "default" an option for inputs?  Use value="0" instead. <input class="other-textbox-stat" type="number" name="attr_pcMeleeWeapEffectPercentage" default="0"/>
1766854970
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
good catch Vince!
1766856729
Maïlare
Pro
Sheet Author
API Scripter
Thanks for your fast answers, I will modify the default by value and test your solution Scott.
1766921690

Edited 1766921883
Maïlare
Pro
Sheet Author
API Scripter
Hello Scott and vÍnce, I managed to get my formula working. The error had three causes: - the "default" attribute, which I changed to "value" - the other attributes I was using, which didn't have a default value and were therefore breaking my formula. - the replacement values } but I'm not sure it's a real problem because I used it in others sheet and it works (but the others sheets are in legacy sanitation, it's perhaps because it's works and not here) Thanks for your help, guys.