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

RollTotal, checking the rolled value against an attribute?

Hey guys, I'm currently making a custom character sheet for the Unofficial Elder Scrolls RPG. I've just reached the point of implementing some custom rolls for various skill checks. Thing is, in UERPG you have character specific 'lucky' and 'unlucky' numbers for both crits and fumbles. What I'd like to know is if there is a simple way of using #rollTotal() to check the roll against one of these lucky/unlucky attributes? Here's where I'm currently at: Roll Template <rolltemplate class="sheet-rolltemplate-check"> <div class = "sheet-rolltemplate-check-container"> <div class ="sheet-rolltemplate-check-header"> {{#title}}<div class="sheet-rolltemplate-check-title">{{title}}</div>{{/title}} {{#subtitle}}<div class="sheet-rolltemplate-check-subtitle">{{subtitle}}</div>{{/subtitle}} </div> <div class = "sheet-rolltemplate-check-content"> {{#allprops() title subtitle luck}} <div class="sheet-rolltemplate-check-key">{{key}}</div> <div class="sheet-rolltemplate-check-value">{{value}}</div> {{/allprops() title subtitle luck}} {{#rollTotal() result luck}} <span>Critical Success!</span> {{/rollTotal() result luck}} </div> </div </rolltemplate> The actual roll <button class = "sheet-skill-rollbutton" type="roll" value= "&{template:check} {{title = Acrobatics}} {{target = @{acrotn}}} {{result = 4}} {{luck = @{luck1}}}" name="roll_AcroCheck">Acrobatics</button></div> I've manually set result to 4 as that is the current value of the luck1 attribute. The target roll value works completely fine when using it in the roll display. It seems that when I try to use the luck value in a rollTotal helper it borks and throws the "Error while checking for roll total..." message.  Here's what the roll looks like, even though 'result' and 'luck' are both definitely 4, nothing appears. Is rollTotal used for something completely different from what I'm thinking? Hopefully I've just stuffed some formatting up somewhere, I'd love to use these roll helpers to keep my sheet a bit more compact. Any advice or tips would be splendid, thanks in advance :)
Ok after banging my head into this issue for a while I actually solved it. There were two main issues with the actual roll line. The first issue was the spaces between the property titles and values. There should be no spaces at all to make sure everything is being fed into the roll template correctly. From:  {{luck = @{luck1}}} To:       {{luck=@{luck1}}} The second issue involved the way roll helpers actually analyse the properties fed into it. Turns out the values fed into rollTotal HAVE to be rolls, even if they aren't rolling any dice. I found this out from Jakob's comment on this forum thread .  From:  {{luck=@{luck1}}} To:       {{luck=[[@{luck1]]}}} This is the output after these changes: So I ended up solving my own issue, but if anyone has any suggestions/tips on how I could improve my roll template game I'd be happy to hear them :)
1597510315
GiGs
Pro
Sheet Author
API Scripter
You might be able to simplify the code by using rollWasCrit() and rollWasFumble(), if you set the roll up with those values. You havent included the initial roll but it would look something like  1d20c<@{luck} This would show a critical if roll is equal or under luck attribute, and you dont have to pass the luck attribute directly. Just use rollWasCrit() to detect the critical.
I actually realised that a little bit later myself after learning more about the dice macros. I ended up making a small sheetworker script to store the 'luck' portion of the roll as an attribute so I could use it for all skill checks. Sheetworker: on("sheet:opened", function(eventInfo) { setAttrs({ luckrolls:"{{result=[[1d100cs@{luck1}cs@{luck2}cs@{luck3}cs@{luck4}cs@{luck5}cf@{unluck1}cf@{unluck2}cf@{unluck3}cf@{unluck4}cf@{unluck5}]]}}" }); }); New roll macro: "&{template:check} {{title=Acrobatics}} {{target=[[@{acrotn}]]}} @{luckrolls}" New roll template: <rolltemplate class="sheet-rolltemplate-check"> <div class = "sheet-rolltemplate-check-container"> <div class ="sheet-rolltemplate-check-header"> {{#title}}<div class="sheet-rolltemplate-check-title">{{title}}</div>{{/title}} {{#subtitle}}<div class="sheet-rolltemplate-check-subtitle">{{subtitle}}</div>{{/subtitle}} </div> <div class = "sheet-rolltemplate-check-content"> {{#allprops() title subtitle}} <div class="sheet-rolltemplate-check-key">{{key}}</div> <div class="sheet-rolltemplate-check-value " >{{value}}</div> {{/allprops() title subtitle }} {{#rollLess() result target}} <div class="sheet-rolltemplate-check-crit">Passed!</div> {{/rollLess() result target}} {{#rollGreater() result target}} <div class="sheet-rolltemplate-check-fumble">Failed!</div> {{/rollGreater() result target}} {{#rollWasCrit() result}} <div class="sheet-rolltemplate-check-crit">Critical Success!</div> {{/rollWasCrit() result}} {{#rollWasFumble() result}} <div class="sheet-rolltemplate-check-fumble">Critical Failure!</div> {{/rollWasFumble() result}} </div> </div> </rolltemplate> And finally, the macro card:
1597556740
GiGs
Pro
Sheet Author
API Scripter
You dont need to put that in a sheet worker. You could just create an attribute: <input type="hidden" name="attr_luckrolls" value="{{result=[[1d100cs@{luck1}cs@{luck2}cs@{luck3}cs@{luck4}cs@{luck5}cf@{unluck1}cf@{unluck2}cf@{unluck3}cf@{unluck4}cf@{unluck5}]]}}" /> Note that if luck1, luck2, luck3, etc are single numbers, 1, 2, 3, etc, you can use the < operator, like so: <input type="hidden" name="attr_luckrolls" value="{{result=[[1d100cs<@{luck}cf>@{unluck}]]}}" />