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

Need help coding dice (newish to this so I’m not 100% on what I’m doing)

So I’m trying to code a slight alteration of the Rifts Character sheets just so I can add dice roll buttons to the sheets and have them reference specific values. I’ve successfully added the buttons and the dice it’s meant to roll in, but I’ve hit a snag when trying to make the code compare the result to a set value. Basically I want the button to roll a d100 and compare the result to the skill level of the character rolling and have the result be bordered green for a success and red for a failure and I’ve use the Wiki instructions but it’s just not working. Any advice would be very welcome, thanks again.
1539600430
Ziechael
Forum Champion
Sheet Author
API Scripter
Hi Rishkhan, it would be great to see your work in progress, in this niche instance just the area giving you concern should suffice but it would really help identify any errors :)
1539602825
Finderski
Pro
Sheet Author
Compendium Curator
To do dice comparisons and change the border of the result will require a roll template . You'll specifically want to start here and here . You'd want to pass in the value of the skill as a roll, something like: {{skill=[[1d0+@{skill}}} Then you could use the rollLess helper, with something like: {{#rollLess() roll skill}}do stuff here, including styling the output {{/rollLess() roll skill}}
I’ll absolutely post screenshots, once I get home. I wasn’t expecting replies so quickly lol
Hey I think I know the primary author of that sheet. I'll ping him a link as he is more familiar with the code base. He might be able to aid as well.
Excellent thank you!
1539657155

Edited 1539657335
Kraynic
Pro
Sheet Author
I monkeyed around with that sheet for my games.  I'm added a template to the sheet, but started just using the default.  I had it pull the skill rating and print it on a line after the roll. &{template:default} {{name=**@{character_name}**}} {{@{skill_name}=[[d100cs<1cf>100]]}} {{Skill Rating=@{skill_rating}}} It occurs to me now that instead of having a 1 show green as a critical success and a 100 show as a critical failure, you could probably make the cs/cf work for you.  Maybe something like this. &{template:default} {{name=**@{character_name}**}} {{@{skill_name}=[[d100cs<@{skill_rating}cf>(@{skill_rating}+1)]]}} I think that would pull the skill rating, show it as green if the roll is that or lower, and show it as red if the roll was higher. I ended up adding a custom template to mine that Jakob wrote that can be found here in a thread I made about the default template. Since I changed all the rolls on the sheet out to use the template, I don't remember what it was originally.  And I am too lazy to go look at the moment, but maybe that cs/cf idea will work to insert in whatever formula you are using. EDIT:  Nevermind.  Just realized it was the megaverse sheet instead of the rifts sheet I am using.  I'll still leave this in case the theory might still work for the other sheet.
so this is the code im trying to get to work. Everything works until line 115. thats the code im trying to get to work, but im unsure what im doing wrong.  I did look at a point of reference in the pokemon ultimate sheets, because thats where i got the idea from in the first place. im trying to test this so if i can get it to work, i can apply it to other rolls on the rifts sheets, such as weapon rolls for attacks and damage.
this is the result of the code if that helps anyone.
1539660289

Edited 1539724304
Kraynic
Pro
Sheet Author
I'm not familiar enough with making sections of sheets.  On the megaverse sheet, the roll for the button is all contained in the value= section, like is shown on line 109.  I'm assuming the attr_OCCT is the full skill rating you are rolling against.  A complete working value may look something like this. value="&{template:default} {{name=**@{Name}**}} {{@{OCCSK}=[[d100cs<@{OCCT}cf>(@{OCCT}+1)]]}}" From looking at the sheet, I think @{Name} will pull the character name, @{OCCSK} is the name of the skill, and @{OCCT} is the full skill rating.  If any of that is off, you would need to adjust it to have the correct label.  I admit that doesn't help you with the other section you are writing which may make the output more presentable in some way, and avoid using the default template.  Hopefully someone will come along that can address that! Edit:  I tried doing this on my sheet, and it will not accept a calculation as part of cs/cf.  I can't get it to accept a ( in that part of the macro.  However, you can still use the call.  This will work to make a higher roll red and a lower roll green.  I haven't played with it enough to see what it does when you land exactly on the OCCT number, but my guess is that it will be outlined in blue since it qualifies as both cs and cf. value="&{template:default} {{name=**@{Name}**}} {{@{OCCSK}=[[d100cs<@{OCCT}cf>@{OCCT}]]}}"
1539689496
Finderski
Pro
Sheet Author
Compendium Curator
Rishkhan, the problem you're having is the roll template code goes in it's own section of the character sheet.  I put mine at the very end.  However, Kraynic has hit upon something that may be easier than a roll template, so you may want to try that.   If you still want to do a roll template, then Kraynic also shows to format the call, though a custom template will have slightly different calls--you'd want to read the links posted above about creating custom roll templates.  But, to give you an example of a full roll template, see below...I hope this helps <rolltemplate class="sheet-rolltemplate-spadestrait2"> <h2 class="sheet-caption">{{name}}</h2> <div class="sheet-rtcard"> <table> <caption>{{skill_name}}{{#skill_nameHeader}}:<br />{{skill_nameHeader}}{{/skill_nameHeader}}</caption> <tbody> <tr class="sheet-rth"> <th colspan="2"><span data-i18n="roll-results">Roll Results</span></th> </tr> <tr> <td class="sheet-rresults">   {{skill_name}}{{#skill_rank}}(d{{skill_rank}}{{#skill_rank_mod}}+{{skill_rank_mod}}{{/skill_rank_mod}}){{/skill_rank}}:</td> <td class="sheet-rollresults">{{skill_roll}}</td> </tr> {{#^rollTotal() mook 0}} {{#wild_die}} <tr> <td class="sheet-rresults">   <span data-i18n="wild-die">Wild Die</span> {{#wild_die_rank}}(d{{wild_die_rank}}){{/wild_die_rank}}:</td> <td class="sheet-rollresults">{{wild_die}}</td> </tr> {{/wild_die}} {{/^rollTotal() mook 0}} <tr class="sheet-rth"> <th colspan="2"><span data-i18n="modifiers-applied">Modifiers Applied</span></th> </tr> {{#^rollTotal() enc 0}} <tr> <td>   <span data-i18n="encumbrance">Encumbrance</span>:</td> <td class="sheet-fakeroll" style="text-align: right;">{{enc}}</td> </tr> {{/^rollTotal() enc 0}} {{#^rollTotal() wounds 0}} <tr> <td>   <span data-i18n="wounds">Wounds</span>:</td> <!--<td class="sheet-fakeroll">{{wounds}}</td>--> <td class="sheet-roll">{{wounds}}</td> </tr> {{/^rollTotal() wounds 0}} {{#^rollTotal() fatigue 0}} <tr> <td>   <span data-i18n="fatigue">Fatigue</span>:</td> <td class="sheet-roll">{{fatigue}}</td> </tr> {{/^rollTotal() fatigue 0}} {{#^rollTotal() other_mods 0}} <tr> <td>   {{other_mods}}</td> <td class="sheet-roll">{{other_mod_vals}}</td> </tr> {{/^rollTotal() other_mods 0}} {{#sit_notes}} <tr> <td colspan="2">   <strong><span data-i18n="situational-notes">Situational Notes</span></strong>:{{sit_notes}}</td> </tr> {{/sit_notes}} {{#allprops() mook enc wounds fatigue}} <!--{{#^rollTotal() #allprops(key) 0}}--> <tr> <td>   {{key}}:</td> <td class="sheet-fakeroll">{{value}}</td> </tr> <!--{{/^rollTotal() #allprops(key) 0}}--> {{/allprops() mook enc wounds fatigue}} {{#notes}} <tr> <td colspan="2">   <strong><span data-i18n="notes">Notes</span></strong>: {{notes}}</td> </tr> {{/notes}} </tbody> </table> </div> </rolltemplate>