General Discussion Undecided where to post - do it here. |
Reply to Thread New Thread |
![]() |
#1 |
|
Spent about an hour rigging this up for Whatah. As it turns out, we can't even use it because we need the random numbers to remain constant for all users. Planning on revising it with a much trickier method
![]() Figured someone might be interested in this. Critique away! [dice=5]20[/dice] Output: [dice=5]20[/dice] Hook Location: bbcode_parse_start Code: Code
if (!function_exists('handle_dicetag')) { srand((double) microtime() * 1000000); function handle_dicetag(&$parser, $param, $option = '') { $numSides = 6; $numDice = 1; $htmlOut = ' |
![]() |
![]() |
#3 |
|
|
![]() |
![]() |
#4 |
|
|
![]() |
![]() |
#5 |
|
|
![]() |
![]() |
#6 |
|
Hm? The only restrictions I put for the inputs are:
#dice: between 1 and 12. #sides: between 1 and 256. Also, it's PHP. BBCode is just the name of the identifiers used by the parser to determine what effects to apply. ![]() EDIT: Oh! That's just a bit of formatting. If you only have 1 di, it prints out "a d20" instead of "1 d20's". I figured Jedah would murder me if I didn't do that ![]() |
![]() |
![]() |
#7 |
|
|
![]() |
![]() |
#8 |
|
|
![]() |
![]() |
#9 |
|
The first two lines are because I don't trust weak typing. I'm explicitly telling it to convert the string values, read in as a base-10 number, to an integer. making sure people don't bug your function hehe |
![]() |
![]() |
#11 |
|
Format is being changed slightly
[dice]20|20|6|6|20[/dice] Would roll 5 dice: 2 d20's, 2 d6's, and another d20. The reason for this is I'm reserving the option value of the bbcode for a generated random number seed, to ensure that the number remains constant. For example: You post: [dice]20[/dice] On submitting, the post is parsed for any instances of "[dice"; if they don't immediately follow by "=" and a number, the tag will be modifed to use the current server-time in milliseconds as a random number seed. So it becomes: [dice=12098503123304]20[/dice] If you're not familiar with random numbers, a seed is a value passed to a pseudo-random number generator that it uses to create random numbers. Two identical seeds will generate the same random numbers. This will also allow you to grab various sets of values by simply reproducing the tag. |
![]() |
![]() |
#12 |
|
|
![]() |
Reply to Thread New Thread |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
|