How to Check for Botch With Roll Template?

1505312518
Ryan
Pro
I'm trying to program a custom roll template for my oWoD game, and I'd like the roll template to display a different background if the player rolls a botch. In case you aren't familiar with old World of Darkness' mechanics and botch rules:  The player rolls a number of d10's, and compares each one to a difficulty number.  Each die that equals or exceeds the difficulty counts as a success, while any 1's that are rolled subtract a success.  A botch occurs if (A) none of the dice beat the difficulty (i.e. no successes are rolled), and (B) at least one '1' is rolled.  So, rolling 5 dice against a difficulty of 6: 8, 8, 8, 4, 1 --> 2 successes 4, 4, 4, 4, 1 --> Botch (no successes, and at least one 1) 8, 4, 1, 1, 1 --> Failure (the '8' prevents it from being a botch, even though the 1's reduce the successes below 0) Is there a way to check an inline roll for the conditions of a botch, and then use a  #property block to select the appropriate table element (styled with the proper background image)?  I've got a decent handle on the API and sheet worker scripts, and I have a reasonable understanding of roll templates, so hopefully all I need is a push in the right direction! Thanks in advance for your help!
1505314091
The Aaron
Pro
API Scripter
It might be possible to play with the critical success and failure condition, maybe like this: [[@{stat}d10cf1cs>@{success}]] Then check to see if the roll is not a critical and is a critical failure, which should indicate a botch.  If you aren't using critical success for something else.  But that might get in the way of grouping for success counts. I've written a few API scripts that handle this sort of mechanic for other games
1505316988
Ryan
Pro
Thanks for your quick reply (as usual!) Would it be possible/advisable to use a sendChat() callback in the sheet worker script to interrupt the inline roll, do the calculations manually, and then export the finished rolltemplate to chat with everything sorted out that way?  All things considered, I'd like to be able to process the roll in an API script---that way I know I can customize it with any bells and whistles I inevitably come up with in the meantime ;)
1505318077
The Aaron
Pro
API Scripter
Well, SheetWorkers don't have access to sendChat(), but your rolls could issue an API command instead of a RollTemplate and then you could process them in the API and have it output the RollTemplate (or just raw HTML).
1505318591
Ryan
Pro
Can I issue API commands via a character sheet button?  (And, if so, how do I do it?)  Or is the only option to submit the roll via a macro or something else?
1505319888
The Aaron
Pro
API Scripter
It definitely can.  I've not messed with it at all, but it should be as simple as replacing your "&{template:....}" bit with "!some-command with args...".
1505320028
Jakob
Pro
Sheet Author
API Scripter
Ryan said: Can I issue API commands via a character sheet button?  (And, if so, how do I do it?)  Or is the only option to submit the roll via a macro or something else? You can just put the API command "!blabla blablabla @{bla}" as the value for a roll button, like any other chat command.
1505396792
Ryan
Pro
Thanks a ton guys!  I've got it to work rather nicely! :D
1505397307
The Aaron
Pro
API Scripter
Nice!