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

Negative numbers in roll template helper functions

I'm guessing helper function values cannot be negative such as {{#rollbetween() total -1 1}}  or {{#rolltotal() total -1}}?
1612298917
GiGs
Pro
Sheet Author
API Scripter
yes, they dont' work with negative numbers unfortunately. I discovered this when working on the tog eternity sheet, and raised the values being compared by 10, so they wouldn't be negative. But if you want to report the roll that presents difficulties!
Man, I was afraid of that.  I thought about raising the values as well to make them positive but I might have to up it by 20 or so.  I think I should be ok with not displaying the result roll itself though. I can just display the other rolls ( hits + pool hits - opposed hits) and not display the total (because it will be 20 higher than expected) and rely on the template output to indicate damage staging up or down.   Thanks GiGs!
1612301941
GiGs
Pro
Sheet Author
API Scripter
You could use the Reusing Rolls method (see the wiki under that title). This allows you to create your roll, then add 20 to it, like so [[ [[1d20+@{skill}]] +20]] Then you can refer to your roll as $[[0]] and the version of it with the +20 as $[[1]] and pass those to your roll template.  It's hard to be more detailed without seeing how your rolls work. But lets say you are making an attack roll that normally looks like this: &{template:default} {{name=An Example}} {{Attack=[[1d20+@{skill}]] }} you'd convert that into the rolltemplate version like &{template:default} [[ [[1d20+@{skill}]] +20]] {{name=An Example}} {{Attack=$[[0]] }} {{comparison=$[[1]] }} Here the comparison  key isn't used for print out - it's just used to generate a value for your helper function comparisons, and you have the unmodified attack roll for display and normal use.
1612361376

Edited 1612362076
Ya I've been beating my head against the reusing rolls trick and finally managed to get it working I believe. Its a bit embarrassing how much of a mess it is but here is my sheet roll. I'll play around with adding 20 this morning but as long as I don't add anymore [[ ]] values I think it will work fine.  Edit- Sorry, that wasn't the most recent iteration.  {template:damageresist} {{type=Balistic Armor}} {{attack=[[?{How many Attack successes?|}]]}} ?{What is the attack's power?|4} {{damage=?{What is the attack's damage level?|Light|Medium|Serious|Deadly}}}[[ [[ [[@{body|max} + @{dermalarmour}]]d6>[[(2+ (?{What is the attack's power?|4} - @{balistic}) + abs(2 - (?{What is the attack's power?|4} - @{balistic})))/2]]!! ]]+ [[ [[?{How many dice are you taking from your Combat/Karma pool?|0}]]d6>[[(2+ (?{What is the attack's power?|4} - @{balistic}) + abs(2 - (?{What is the attack's power?|4} - @{balistic})))/2]]!! ]] - (?{How many Attack successes?|} [[@{body|max}d6>[[{floor(?{What is the attack's power?|4}/2),2}kh1]]!!]]]]{{roll= $[[4]]}}{{poolroll= $[[6]]}}{{total=$[[9]]}}{{knockroll=$[[8]]}}
1612366946
GiGs
Pro
Sheet Author
API Scripter
That is a very complex roll! I'm surprised you need this > in your roll have you tried with a normal >?
thanks! really helpful
The > was a carry over from the original sheet (I'm trying to rework/update/add to the ShadowRun 2e sheet) that I just had not replaced yet but a normal > does work just fine.  The goal is to get everything working, old and new, so I can start my game back up then work on cleaning up the code (replacing tables with divs and hopefully later on grids, etc) and making the sheet and rolls all pretty and fancy in baby steps along the way.  At some point I'm hoping to submit it to be an available system sheet rather than just a custom.