Using the XdYe dice expression, for example 5d6e, I get just the total.
Using XdYo (5d6o), I get: "Dice: 15, 1, 1, 3, 5, Maximum: 15"; basically, a string (in fact, if I use 1d20e + 5d6o, I get the string immediately after the d20 result). If I have to use it often (which I'll have), it would be quite annoying to alway use a function to extract the single rolls, remove the string, and add them up.
So, the question is: what would be the best way to get both the single exploded rolls and their sum?
Exploding dice results
Moderators: dorpond, trevor, Azhrei, giliath, jay, Mr.Ice
Exploding dice results
"There are many ways my Son, to find where the souls of Demons remain...
But it takes only one second of despair and of doubt until, at last, your Soul they will gain..."
But it takes only one second of despair and of doubt until, at last, your Soul they will gain..."
Re: Exploding dice results
I'm sure there's code around here showing how to do it. I know I've written stuff similar, but this may be what you're looking for: http://forums.rptools.net/viewtopic.php ... ng#p197114
Downloads:
- Notepad++ MapTool addon
- RPEdit details (v1.3)
- Coding Tips: Modularity and Design
- Videos: Macro Writing Tools
- JamzTheMan
- Great Wyrm
- Posts: 1872
- Joined: Mon May 10, 2010 12:59 pm
- Location: Chicagoland
- Contact:
Re: Exploding dice results
If I were to tackle it, I would probably just use a for-loop, doing one exploding die at a time, tracking total, and, individual rolls. (although a regular expression replace could probably be done on the other string to strip and sum.
In any case, yes, create a macro, then define it as a UDF like, explodeMyDice(num, sides), if sides is needed. Have it either return a formatted output if that's what you need, or if you need to do more work, return a json with {total:sumOfResult, rolls:"1,4,2,5"}.
Of course, rolls: could also be an array []. It all depends on what you are doing with the results...
In any case, yes, create a macro, then define it as a UDF like, explodeMyDice(num, sides), if sides is needed. Have it either return a formatted output if that's what you need, or if you need to do more work, return a json with {total:sumOfResult, rolls:"1,4,2,5"}.
Of course, rolls: could also be an array []. It all depends on what you are doing with the results...
-Jamz
____________________
Custom MapTool 1.4.x.x Fork: maptool.nerps.net
Custom TokenTool 2.0 Fork: tokentool.nerps.net
More information here: MapTool Nerps! Fork
____________________
Custom MapTool 1.4.x.x Fork: maptool.nerps.net
Custom TokenTool 2.0 Fork: tokentool.nerps.net
More information here: MapTool Nerps! Fork