
I saw a thread ( https://app.roll20.net/forum/post/149507/request-slash-suggestion-roll-total-vs-target-number#post-149664 ). I don't play GURPS, but I was curious if it would be possible to do some more advanced comparisons. I put together this script to allow you to compare an arbitrary expression with attribute value substitution to the result of a die roll.
So the API doesn't have a direct interface into the dice roller, and I didn't want to try to recreate all the advanced features, so I came up with this syntax:
/r [dice expression here] [comment here] |<| @DEX
/r 3d6 Dex Check! |<| @DEX
The idea being that the dice roller would complete the roll as normal, in this case 3d6. The API script checks every roll to see if it has an operator in a pipe, and if so it compares the total from the die roll to whatever expression is to the right of the operator, substituting attributes from whoever you are sending the roll chat as. It is doing very basic attribute substitution, so there could be some bugs.
https://gist.github.com/rlittlefield/5545693?1=7
Edit: forgot to mention that this will say "Success (-3)", "Success (2)" or "Failure", depending on the truthiness of the expression. Edit 2: If you don't like the number in the success parenthesis (currently the difference between the roll total and the expression total) being a negative number when you do your less-than comparison, the code could be adjusted to get an absolute value of the difference.
Update (2013-09-22): I've added GManator's request to have this work with /gmroll. It will whisper the results to both the GM and the player doing the roll. It does this using player names, which could get complicated if everyone has the same first name, so don't treat this as completely secure. If it can't figure out what a players name is, it will complain to the GM through a whisper.