# Got dice?



## Morrus

Playing a PbP game? Need to roll some dice?

[dice]

I've implemented a new code, with which you can perform a die roll. You can roll as many as 3 dice of 30 faces and as few as 1 die of 2 faces. Once you roll the dice it is stored in the post so you cannot roll again even if you edit the post or whatever.

*How to use it:*

[dice={dices}]{faces}[/dice]

*Examples - replace ( and ) with [ and ] in the below examples:*

(dice=2)10(/dice) (This will roll 2d10)

(dice=1)6(/dice) (This will roll 1d6)

Remember, the code works for a maximum of 3 dice, and only between 2-30 faces on each.


----------



## Morrus

And another roll:

[dice]


----------



## Morrus

And another:

[dice]


----------



## Olgar Shiverstone

Can I try?

Strength: [dice]

Intelligence: [dice]

Wisdom: [dice]

Dexterity: [dice]

Constitution: [dice]

Charisma: [dice]

Edit: Hmm ... apparently only works once per post.


----------



## Creamsteak

Holy... niceness...

Is there any way of editing the code so that the greyspace doesn't stretch out? And if a user deletes the entire text of their post and then repeats the process, does it change the results? Any way of having a version with no image? Can you add modifiers?

Just three obvious questions, and I'll test out one right now:
[dice]


----------



## Morrus

Olgar, you can only do it once per post.  The system remembers one result for each post you make.

Creamsteak, I'm not good enough to change it like that (I just copied and pasted to get it working).  

You cannot put the code in when editing a post, so if you try and edit your post, it won't work.


----------



## Olgar Shiverstone

Makes online character generation, combat, and the like a little post-intensive.

Still, a very neat tool.  Thumbs up!


----------



## Creamsteak

I know just enough java now to make my own dice roller executables... don't think I could be too helpful though.


----------



## Morrus

Creamsteak said:
			
		

> Is there any way of editing the code so that the greyspace doesn't stretch out?



How's that?  Better?


----------



## Creamsteak

Much. Can you de-center it too? Or can I affect it with type tags?​


----------



## hong

Morrus, I wouldn't mind having a look at the random number generation code.


----------



## Morrus

hong said:
			
		

> Morrus, I wouldn't mind having a look at the random number generation code.



You can have a look at everything I used.  Basically, it was a single page of instructions on code changes to make.  I didn't understand it - just copied and pasted.  I've attached the instructions here.


----------



## Creamsteak

So if you change align="center" to align = left and add replace most of the bracketed dice stuff with "DiceL" could you have a dice left and a dice right command? And what about if you make a ShortDice without the image, and just put the number itself on the page? 

Hell, I've got no idea what I'm saying, but that's doesn't look to hard to screw around with.


----------



## hong

Morrus said:
			
		

> You can have a look at everything I used.  Basically, it was a single page of instructions on code changes to make.  I didn't understand it - just copied and pasted.  I've attached the instructions here.



 Suggestion: replace rand() in 



		Code:
	

                        	$dicedetail['data'][] = rand(1,$faces);


with mt_rand(). rand() uses the default random number generator provided by the server, and this can have poor statistical properties especially on older systems.

http://www.php.net/manual/en/function.mt-rand.php

Trust me, I'm a statistician.


Hong "no, really" Ooi


----------



## Creamsteak

Nice... I'll steal that little bit from Hong...


----------



## Morrus

Sounds easy enough.

Say, don't s'pose anyone would know how to

1) Allow multiple rolls in a post;
2) Show different graphics depending on the die type (I don't mind limiting it to "real" dice instead of anything between 2 and 30 - it would require quite a few dice to be drawn, but I'm sure that could be done).


----------



## Zappo

Ooh, lemme try...
 [dice]


----------



## diaglo

sweet.  

[dice]


----------



## diaglo

Creamsteak said:
			
		

> Holy... niceness...
> [dice]





you wait patiently after casting your spell.. suddenly you feel strange. as if you are here but not here.

another voice enters your mind.

Hiya....

your _find familiar_ spell has summoned a special form...one of true kindred with your spirit.

a pseudo dragon.


----------



## Hand of Evil

[dice] and roll I do


----------



## Hand of Evil

[dice=5]4[/dice] and four sided...


----------



## Hand of Evil

Hand of Evil said:
			
		

> [dice=5]4[/dice] and four sided...



guess there is not a four side dice.


----------



## Hand of Evil

[dice] 12er


----------



## hong

diaglo said:
			
		

> you wait patiently after casting your spell.. suddenly you feel strange. as if you are here but not here.
> 
> another voice enters your mind.
> 
> Hiya....




As soon as you said that, I thought of this person:







Which is scary, given it's been ~4 years since I last played any of the Baldur's Gate games.


----------



## Creamsteak

Hand of Evil, your problem is that your trying to call 5 dice at a time, and the limit is 3.


----------



## Hand of Evil

Creamsteak said:
			
		

> Hand of Evil, your problem is that your trying to call 5 dice at a time, and the limit is 3.



[dice] it is not my only one


----------



## diaglo

hong said:
			
		

> Which is scary, given it's been ~4 years since I last played any of the Baldur's Gate games.




well at least it was Imoen you thought of and not the stupid Mouse and his handler.


----------



## JoeBlank

Ohh, fun!

[dice=1]100[/dice]


----------



## JoeBlank

Or not fun. What did I do wrong?

[dice]


----------



## JoeBlank

Maybe it just can't handle d100?


----------



## diaglo

JoeBlank said:
			
		

> Maybe it just can't handle d100?




only upto and including 30 sides

RTFM...


----------



## Morrus

JoeBlank said:
			
		

> Maybe it just can't handle d100?



Sure it can.  Roll 2d10.


----------



## Barendd Nobeard

Morrus said:
			
		

> Sure it can.  Roll 2d10.




Cool.

[dice]


----------



## Morrus

You rolled 00?  You lucky guy!

[dice]


----------



## LightPhoenix

I'm still working on learning PHP and databases, but from what I can tell, altering it so that you can have two different dice rolls won't work, based on the way it stores the data in a/the database. I'm not really convinced the way this was coded is necessarily the best way, but on the other hand it's constrained by the fact that you do need to record the data somewhere, because you want everyone to see the same number.

EDIT:

[dice=1]9[/dice]

So apparently, it's not "up to and including 30", but a specific subset?  Or I'm a tool and can't get it to work, one of the two.


----------



## LightPhoenix

[dice]

Let's see if this works...

EDIT: And it does, further demonstrating how the database storage works.  The first time I put in an illegal dice roll - 3d1.  It didn't like that, but changing the parameters didn't work, because the dice function is stored with the message.  So I had to post it in a new reply to get it to work.


----------



## diaglo

LightPhoenix said:
			
		

> [dice]
> 
> Let's see if this works...
> 
> EDIT: And it does, further demonstrating how the database storage works.  The first time I put in an illegal dice roll - 3d1.  It didn't like that, but changing the parameters didn't work, because the dice function is stored with the message.  So I had to post it in a new reply to get it to work.





pssstttt...rtfm...Morrus's posts...says max 3 dice. with sides from 2 to 30.

clip here is an important part :  







			
				Morrus said:
			
		

> (I don't mind limiting it to "real" dice instead of anything between 2 and 30 - it would require quite a few dice to be drawn, but I'm sure that could be done).


----------



## JoeBlank

Some of us were just too excited to pay attention to the details!


----------



## LightPhoenix

diaglo said:
			
		

> pssstttt...rtfm...Morrus's posts...says max 3 dice. with sides from 2 to 30.
> 
> clip here is an important part :



While your attitude isn't appreciated, thank you for pointing that out.  When I switched from 3d1 (which for some reason didn't register as being invalid) to 1d9, I mistakenly assumed that d9 was invalid, when in fact it was due to the database storing the invalid dice roll.  All of which I stated in my post above, if you'd bothered to read it.

What would the abbreviation for that be, rtfp?


----------



## Argent Silvermage

too cool! thanks.


----------



## LightPhoenix

LightPhoenix said:
			
		

> While your attitude isn't appreciated, thank you for pointing that out. When I switched from 3d1 (which for some reason didn't register as being invalid) to 1d9, I mistakenly assumed that d9 was invalid, when in fact it was due to the database storing the invalid dice roll. All of which I stated in my post above, if you'd bothered to read it.
> 
> What would the abbreviation for that be, rtfp?



Mwahaha, replying to myself.  

Diaglo, I'd like to apologize to you. I shouldn't have been snippy at you.  I'm sorry.


----------



## diaglo

LightPhoenix said:
			
		

> Mwahaha, replying to myself.  I'm sorry.




me, too. i wasn't trying to be nasty.


----------



## pogre

Just testing the die roller. Mostly because I am thick and I want to see if I can figure it out.
[dice]


----------



## Jeph

Hey, cool.

[dice]


----------



## GPEKO

Let's try this ...

[dice=1]20[/dice]

Edit: Seems I can't edit the post and keep the dice roll intact


----------



## Altamont Ravenard

better late then never!

[dice]

AR


----------



## Altamont Ravenard

test: [dice]


----------



## Altamont Ravenard

last time: [dice]


----------



## Altamont Ravenard

wow, out of a maximum of 18 + 8 + 20 = 46, I've scored an amazing 10! Woot me!

AR


----------



## Creamsteak

The 3d6 calls have been 112, 122, and 112.

[dice]


----------



## diaglo

[dice]

i love this.


----------



## Creamsteak

We need to write up a  code! Generating a full ability score array.


----------



## Creamsteak

[dice]
[dice]
[dice]


----------



## Creamsteak

Huh... that's weird. I typed 1d6, 2d6, 3d6 and it changes it to a flat 3d6 three times.


----------



## LightPhoenix

Creamsteak said:
			
		

> Huh... that's weird. I typed 1d6, 2d6, 3d6 and it changes it to a flat 3d6 three times.



Only one result per post is stored in the database.  This makes sure that everyone sees the same number, and that it can't be tampered with.  Unfortunately this doesn't allow for multiple dice rolls.


----------



## diaglo

Dice, Dice, Baby...

[dice]

bumping for the General crowd....read LightPhoenix's post just above this one....


----------



## Cerubus Dark

[dice]

roll beast roll!


----------



## RangerWickett

I'll needlessly pad my post count, since no doubt this will be deleted soon.
[dice]

Can we get some different graphics?  Bright blue don't go too well with dark grey boards.  Of course, this is a minor minor minor issue.


----------



## RangerWickett

13 and . . .

[dice]


----------



## RangerWickett

13, 10, and

[dice]


----------



## RangerWickett

13, 10, 7, and

[dice]


----------



## RangerWickett

13, 10, 7, 14, and 

[dice]


----------



## RangerWickett

13, 10, 7, 14, 13, and 8

[dice]

D'oh!  Hey, Russ, can we get some dice that roll hotter?  My stats stink.  I was gonna play a sorcerer-rogue, and what have I got now?

Str 7
Dex 13
Con 10
Int 13
Wis 8
Cha 14

If you really want to mess with your heads, code it so you can roll 4d6, take the best 3.  But seriously, rolling lots of dice this way is too time- and post-intensive.  It might be nifty as a feature, but it'd be easier to just have, like, a link at the top of some of the in-character forums, which you click on to open a dice-roller applet.


----------



## axehand

lets see if i can do this

[dice]


----------



## axehand

i like it

[dice=1]10[/dice]


----------



## dndonlinegames

Test.

This is cheat proof.

[dice]d6[/dice]


----------



## Chacal

Cheating attempt failed


----------



## Chacal

Die Roll: 1d4
[dice]


----------



## diaglo

Chacal said:
			
		

> Die Roll: 1d4
> [dice]





only problem is i can tell this is a pic only and not an actual roll.


----------



## Chacal

diaglo said:
			
		

> only problem is i can tell this is a pic only and not an actual roll.



Wrong. 
This is an actual roll. If it wasn't, I could have know the number of the roll and put into parentheses like it normally does.

Select the whole post and you'll see how I cheated

Let's try if it's different with your technique :

Die Roll: 1d4 (13) 







Chacal


----------



## Chacal

It's still easy to see when one cheats. You just have to reply.
If you used the [Dice], then it shows it in your post.

in the first method I put a black color so  dice is hard to see (in black)
in the second method you can see the pic .

In both cases you know I cheated



Chacal


----------



## MrFilthyIke

Rescurrecting thread, to test this "dice" thing 

edit grr


----------



## MrFilthyIke

try again

(dice=2)10(/dice)

edit: does this still work?  i'm so behind on things


----------



## diaglo

no the dice bot is offline right now.

it was mentioned in another thread by Michael Morris but i can't remember where.


----------



## MrFilthyIke

Dang, I only just found it in a story hour, never knew about it.  I don't normally drift into SH.


----------



## Michael Morris

An error in the dice script was causing the thread posting features to go wonky.  It's on my list of things to fix, but not a priority.


----------

