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

Clarification on parsed custom roll variabiles and function

1675382787

Edited 1675382897
Hello again, I'm approaching a critical part of my cutsom sheet dev, cutsom roll parsing for my game logic. After reading the wiki about custom rolls and messing around in the sandbox I cannot get a grip of some logic in the flow of the function, so taking the main example from the wiki: <button type="action" name="act_test">Click me</button> <rolltemplate class="sheet-rolltemplate-test"> <div class="sheet-template-container"> <h1>{{name}}</h1> <div class="sheet-results"> <h4>Result = {{roll1}}</h4> <h4>Custom Result = {{computed::roll1}}</h4> </div> </div> </rolltemplate> <script type="text/worker"> on('clicked:test', (info) => { startRoll("&{template:test} {{name=Test}} {{roll1=[[1d20]]}}", (results) => { const total = results.results.roll1.result const computed = total % 4; finishRoll( results.rollId, { roll1: computed } ); }); }); </script> I want to understand the logic behind thie finishRoll function 2nd argument  and it's relation in the roll template HTML. Let's start with statement from the wiki, it says:  To use the custom computed results in your roll templates, replace the roll names in the template with computed::< rollname > Okay clear, then in the example I see that in the finishRoll function the JS object property passed has : roll1:computed Now I'm assuming that the function takes a JS object which keys are: finishRoll(rollID, {     rollname: value,... }); Where the rollname key is one of the rollname i choose to use after the computed string in the html. But when I go to modify the rollname with one different  from roll1   it does not work anymore, in the sense that I get no result in the final HTML. So the   rollaname  is tied  to any property name I used before in the HTML template? If this is the case then I did not notice where it's written in the wiki. Thanks for the attention; and let me say that I'm having a blast working with this sheet codes, the amount of work behind all this is monumental, kudos to the devs at roll20 and to all the peapole who wrote the wiki and help here on the forum, you guys rock.
1675383512
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Computed values have three requirements to display a changed value: It must be referenced in the html of the rolltemplate. Either directly (e.g. {{computed::myfield}} ), or by having an allProps section in the roll template. This is true of any roll template field. The field must have had an inline roll in it to start with. I usually do {{myfield=[[0[computed value]]]}} . You must pass the field name and new value as a key:value  pair in the object that is the second argument to finishRoll
1675385885

Edited 1675385914
Scott C. said: Computed values have three requirements to display a changed value: It must be referenced in the html of the rolltemplate. Either directly (e.g. {{computed::myfield}} ), or by having an allProps section in the roll template. This is true of any roll template field. The field must have had an inline roll in it to start with. I usually do {{myfield=[[0[computed value]]]}} . You must pass the field name and new value as a key:value  pair in the object that is the second argument to finishRoll Now it's more clear, with this new knowledge I'll mess around in the sandbox tomorrow and hopefully get a grip on this topic. Thank you for the swift answer.