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

Evaluating roll results in two contexts?

December 19 (7 years ago)
OptionalRule
Sheet Author
I'm trying to create a rolltemplate that needs to evaluate a roll result twice.  Once for success (is it below a particular target number) and once to determine if it's a critical (the raw roll is evenly divisible by 5).  I know how to do each individually but I need to do both against the roll result and not sure I can do it.

In the roll button I generate:
{{rolltarget=[[@{INITIATIVE_ML} - @{PHYSICAL_PENALTY}]]}} 
{{rollresult=[[1d100]]}}

So checking for success in the template is simple enough but to check for a crit I'd have to make sure rollresult%5 was 0 which means I'd have to be able to either access the that value again in the value generating the rolltemplate (I don't think I can do that) or calculate it in the rolltemplate (also don't think I can do).

Am I missing something or is there a work around I'm not considering?

Thanks for any feedback.
December 19 (7 years ago)
as far as i am aware you may have to do them separately but then again i'm no code ninja. you are correct that you can not modify a roll once it is rolled but you might be able to program a series of dice rolls then compare those over/under a target number to generate a sort of toal of success world of darkness uses a simialr setup. from the verbage of your roll i am gonna say your using pathfinder or 5e. 
December 19 (7 years ago)
OptionalRule
Sheet Author
 lordmage said:
as far as i am aware you may have to do them separately but then again i'm no code ninja. you are correct that you can not modify a roll once it is rolled but you might be able to program a series of dice rolls then compare those over/under a target number to generate a sort of toal of success world of darkness uses a simialr setup. from the verbage of your roll i am gonna say your using pathfinder or 5e. 
Thanks for the answer.  It looks like I'd have to do them seperatly.  What I can't figure out is how do I access the exact same dice roll result in two places I can do an evaluation since I can't seem to do it in the template?   It's one die roll if that wasn't apparent.  You roll once and determine if it's below or above the target number and also if it's divisible by 5.

December 19 (7 years ago)
Lithl
Pro
Sheet Author
API Scripter
Since you're a Pro subscriber, you could use the PowerCards API script which gives you this functionality (among others).
December 19 (7 years ago)

Scott T. said:

 lordmage said:
as far as i am aware you may have to do them separately but then again i'm no code ninja. you are correct that you can not modify a roll once it is rolled but you might be able to program a series of dice rolls then compare those over/under a target number to generate a sort of toal of success world of darkness uses a simialr setup. from the verbage of your roll i am gonna say your using pathfinder or 5e. 
Thanks for the answer.  It looks like I'd have to do them seperatly.  What I can't figure out is how do I access the exact same dice roll result in two places I can do an evaluation since I can't seem to do it in the template?   It's one die roll if that wasn't apparent.  You roll once and determine if it's below or above the target number and also if it's divisible by 5.


this might also help https://wiki.roll20.net/Dice_Reference#Roll20_Dice_Specification
December 19 (7 years ago)
OptionalRule
Sheet Author

Brian said:

Since you're a Pro subscriber, you could use the PowerCards API script which gives you this functionality (among others).

Thanks I'll consider that.  It initially doesn't seem like a great solution.  The rolls are critical to the game and character sheet and I'd like to eventually make this sheet available to folks to use broadly.  If I'm not mistaken linking fundamental rolls to macros would hurt portability and reuse?
December 19 (7 years ago)

Edited December 19 (7 years ago)

Scott T. said:

Brian said:

Since you're a Pro subscriber, you could use the PowerCards API script which gives you this functionality (among others).

Thanks I'll consider that.  It initially doesn't seem like a great solution.  The rolls are critical to the game and character sheet and I'd like to eventually make this sheet available to folks to use broadly.  If I'm not mistaken linking fundamental rolls to macros would hurt portability and reuse?

unless you provided instructions for how to structure the macros then each person would have to know which API to use and how but to answer your question yes... maybe you can look at sheetworkers https://wiki.roll20.net/Sheet_Worker_Scripts that might be better in designing and programing a shareable sheet 

there is of course https://wiki.roll20.net/Building_Character_Sheets
December 19 (7 years ago)

Edited December 19 (7 years ago)
GiGs
Pro
Sheet Author
API Scripter
You definitely can evaluate a roll twice in the same roll template. Why not post your rolltemplate code, so we can see exactly what you're doing, and we can suggest tweaks.

One thing you need:
Once for success (is it below a particular target number) and once to determine if it's a critical (the raw roll is evenly divisible by 5).
To get this in a format you can use in a rolltemplate, you need to set up the roll to give appropriate criticals, so that you can use the rolltemplate RollWasCrit function.

Assuming you're using 1d100, this roll will tell the rolltemplate if a result is critical (exactly divisibly by 5). Note that this will set failed rolls higher than skill rating as criticals too, but don't worry, the rolltemplate below will catch that.
/roll 1d100cs5cs10cs15cs20cs25cs30cs35cs40cs45cs50cs55cs60cs65cs70cs75cs80cs85cs90cs95cs100<57
Change the <57 at the end to <@{skill} or whatever the target number is.  If it's a calculation, make sure you use an inline roll, like so:
/roll 1d100cs5cs10cs15cs20cs25cs30cs35cs40cs45cs50cs55cs60cs65cs70cs75cs80cs85cs90cs95cs100<[[@{INITIATIVE_ML} - @{PHYSICAL_PENALTY}]]
Of course, in a roll designed for a rolltemplate, you would have it setup like this, rather than starting it with /roll:
&{template:yourtemplatename} {{name=Test Attack}} {{roll=[[1d100cs5cs10cs15cs20cs25cs30cs35cs40cs45cs50cs55cs60cs65cs70cs75cs80cs85cs90cs95cs100<[[@{INITIATIVE_ML} - @{PHYSICAL_PENALTY}]] ]] }}
Then within your rolltemplate code, you would have something like this:
{{#^rollGreater() roll }}
   {{#rollWasCrit() roll }}
     // enter your code here for what happens when the roll is critical
   {{/rollWasCrit() roll }}

   {{#^rollWasCrit() roll }}
     // enter your code here for what happeneds when the roll succeeds, but is not a critical
   {{/^rollWasCrit() roll }}
{{/^rollGreater() roll }}
Note: ^rollGreater means the roll is NOT greater than "roll", or in other words, IS equal to or less than "roll". 

If something happens when the roll fails, and fumbles also occur on a number divisible by 5, you can expand it like so:

{{#^rollGreater() roll }}
   {{#rollWasCrit() roll }}
     // enter your code here for what happens when the roll is critical
   {{/rollWasCrit() roll }}

   {{#^rollWasCrit() roll }}
     // enter your code here for what happeneds when the roll succeeds, but is not a critical
   {{/^rollWasCrit() roll }}
{{/^rollGreater() roll }}
{{#rollGreater() roll }}
   {{#rollWasCrit() roll }}
     // enter your code here for what happens when the failed roll is divisible by 5
   {{/rollWasCrit() roll }}
   {{#^rollWasCrit() roll }}
     // enter your code here for an ordinary failed roll. 
   {{/^rollWasCrit() roll }}
{{/rollGreater() roll }}
December 19 (7 years ago)

Edited December 19 (7 years ago)
OptionalRule
Sheet Author
That's for that reply, it's what I needed.  I didn't realize you could chain multiple cs checks in a single roll.   I came up with a solution that seems to work based on this.  I broke it out a bit differently so I would have access to the individual numbers to display in the template so players can see what is going on and correct for something we didn't or couldn't think to include in the template roll.

A roll is initialized as follows:
<div>
    <input type="text" class="sheet-skill-label" name="attr_INITIATIVE_NAME" value="Initiative" disabled="true">
    <input type="number" name="attr_INITIATIVE_SB" class="sheet-skill-value">
    <input type="number" name="attr_INITIATIVE_ML" class="sheet-skill-value">
    <button type="roll" value="&{template:skillcheck} {{character_name=@{NAME}}} {{rollname=@{INITIATIVE_NAME}}} {{rolltarget=[[@{INITIATIVE_ML} - [[(@{PHYSICAL_PENALTY})*5]]]]}} {{penalty=[[(@{PHYSICAL_PENALTY})*5]]}} {{rollresult=[[1d100cs5cs10cs15cs20cs25cs30cs35cs40cs45cs50cs55cs60cs65cs70cs75cs80cs85cs90cs95cs100]]}} {{ml=@{INITIATIVE_ML}}}" name="roll_InitiativeCheck" ></button>
</div>
And the template to render it is like so:
<rolltemplate class="sheet-rolltemplate-skillcheck">
    <table>
        <tr><th><span class="tcat">{{character_name}} Rolls {{rollname}}</span></th></tr>
        {{#rollGreater() penalty 0}}
            <tr><td><span class="tcat">Target: </span>({{ml}}-{{penalty}}) = {{rolltarget}}</td> </tr>
        {{/rollGreater() penalty 0}}
        {{#^rollGreater() penalty 0}}
            <tr><td><span class="tcat">Target: </span>{{rolltarget}}</td> </tr>
        {{/^rollGreater() penalty 0}}
        <tr><td><span class="tcat">Roll: </span> {{rollresult}}</td> </tr>
        {{#^rollGreater() rollresult rolltarget}}
            {{#rollWasCrit() rollresult }}
                <tr><td class="sheet-crit-success sheet-center sheet-font-heavy">Critical Success!!</td></tr>
            {{/rollWasCrit() rollresult }}
            {{#^rollWasCrit() rollresult }}
                <tr><td class="sheet-success sheet-center sheet-font-heavy">Marginal Success.</td></tr>
            {{/^rollWasCrit() rollresult }}
        {{/^rollGreater() rollresult rolltarget}}
        {{#rollGreater() rollresult rolltarget}}
            {{#rollWasCrit() rollresult }}
                <tr><td class="sheet-crit-failure sheet-center sheet-font-heavy">Critical Failure!!</td></tr>
            {{/rollWasCrit() rollresult }}
            {{#^rollWasCrit() rollresult }}
                <tr><td class="sheet-failure sheet-center sheet-font-heavy">Marginal Failure.</td></tr>
            {{/^rollWasCrit() rollresult }}
        {{/rollGreater() rollresult rolltarget}}
    </table>
</rolltemplate>
I have to tighten up some of the styles and such but that was very helpful and I appreciate it.
December 20 (7 years ago)
GiGs
Pro
Sheet Author
API Scripter
You're welcome, glad I could help.