Adium
Dock Icons Emoticons Contact List Styles Message Styles Sound Sets AppleScripts Status Icons Service Icons Menu Bar Icons Plugins Miscellaneous All
Dice Roller

Dice Roller

Submitted By Martin Crisp (Hypercube)

Description

Dice Roller:
Rolls dice... like you might use in afantasy role-playing game.

D20 -> Roll a 20-sided die
3D20 -> Roll 3 20-sided dice and total the result
3*D20 -> Roll a 20-sided die and mutiply the result by 3
DD20 -> Roll a die that has as many sides as the result of a rolling a 20-sided die [if a 12 is rolled on a 20-sided die, the take the result of rolling a 12-sided die.]

D10D20 -> roll a 10-sided die, roll that number of 20-sided dice and total the result.

supports addition, multiplication, subtraction & division operators (but no others!). Does not support parentheses to adjust evaluation order.

To use:
%_roll{DiceExpression}
e.g. %_roll{d12+3d4*2-D20} => rolled d12+3d4*2-D20 and the result was: 15

[PS: number ranges and operators affect whether result is a 'real' or 'integer'. Only non-negative integers (0, 1, 2, 3, ...) are allowable for die-size. All individual die results are numbers between 1 and the die size, which means a D0 gives a 0 or 1, and a D1 always gives a 1.]

To install:
Unpack the zip archive, and then double-click the roll.AdiumScripts bundle.

Comments

You can reply to individual comments by clicking the "Reply" link next to each.

# by Reikon on 09/11/04 at 20:14:01

Great script, only problem is it returns "Rolled a D6 Sided Dice" instead of "6 sided" dice and people dont' know what i'm talking about, but it's all good gj man!

# by on 09/12/04 at 02:36:54

It should, and does for me, return 'rolled a and the result was: ' (or display a not very informative dialog if the input isn't valid).

It's easy enough to change it inside the script... (email if you want/need the gory details)
I'll upload a different version if I can get some concensus on a better phrase :-)

Have Fun
Martin

# by on 09/12/04 at 03:23:19

OK, so angle-bracketed stuff gets swallowed.

the result of:
I %_roll{d6}, what happens?

is

I rolled d6 and the result was: 4, what happens?

Isn't that what you're seeing?

Have Fun
Martin



# by Reikon on 09/12/04 at 18:20:36

Yeah, thats what i'm seeing, however people dont' know what i'm talking about especially when i roll a 12 sided dice..

I rolled d12 sided and the result was: 4

people think I'm talking about that rap group or something..if you put in an integer, like:

%_roll{2} it'll return 2..or w/e you put in...like:

I rolled 2 sided dice and the result was: 2

is there any way to make it work with numbers only do "D" isn't returned in there? j/w..otherwise it still owns...

# by Reikon on 09/12/04 at 18:22:02

Blah...I mean make it to where D isn't returned in the result..

# by on 09/12/04 at 23:51:45

OK, I see what you mean now...

Yep, that would be clearer, for simple rolls; but it quickly becomes a pain to understand for more complex rolls.

Perhaps I could change the output so that if there's only one D and no arithmetic operators it gives a more-English result. But I don't think a readily-understandable English equivalent is available for arbitrary rolls.

Alternatively: get 'better' friends ;-)

Have Fun
Martin

# by Reikon on 09/13/04 at 18:16:30

You could just use Apple's Trim text manipulation to remove the D from the result couldn't you? ^_^

# by on 09/13/04 at 21:46:33

Heh. I could, but that doesn't look to make things clearer for more complex input.

%_roll{d12+3d4*2-D20} => rolled 12+34*2-20 and the result was: 15


I'll have a play with re-working the output for simpler rolls (which are more common), but I really can't think of much that can be done to clarify output from more complex input.

Have Fun
Martin

# by Reikon on 09/16/04 at 23:46:09

It's still a great script and you did an awesome job. Thanks!

# by on 09/18/04 at 02:50:59

:-) Thanks

I'm 'getting to' the above revisions, and contemplating a couple of other operators (mod, div, exponentiation), perhaps parentheses. But various bits of life have been keeping me away from my machine...


Have Fun
Martin

# by Cheesus on 08/14/06 at 17:41:33

This script is great. The only thing that I would like to see in a newer version is the
ability to see what each die rolled individually.

For example: %_roll{3d6} => rolled 3d6 and the result was: 3+4+5=12
or perhaps another method of representation.

Just a suggestion, and almost 2 years later, at that.

# by redjag on 09/07/07 at 16:26:44

Very cool script, I also agree a breakdown of the "background" rolling would be great.

# by era on 02/24/09 at 19:52:23

The script is really great, but how Cheesus said it would be very nice if you would write each roll individually: 3d6 -> 3+4+5=12
You could even make this through an extra command, like %_roll_show{3d6}

Another little wish: you could rename your script to roll_dice or dice or something like that because there is allready a roll-function (which does not roll dices, but it has the same name: roll)

Post a New Comment

You must be logged in to post comments.

Install | Download
15.12kb (1606 downloads)

12345
3.00 / 143 votes
Current Version: 1.0
Last Updated: 09/08/04
Credits:
Gary Gygax? I wrote it a year ago for IRC use