[ABD] Dice MOD

Any abandoned MODs will be moved to this forum.

WARNING: MODs in this forum are not currently being supported or maintained by the original MOD author. Proceed at your own risk.
Forum rules
IMPORTANT: MOD Development Forum rules

WARNING: MODs in this forum are not currently being supported nor updated by the original MOD author. Proceed at your own risk.
Locked
coppro
Registered User
Posts: 84
Joined: Wed May 16, 2007 3:10 am

[ABD] Dice MOD

Post by coppro » Thu May 24, 2007 7:28 pm

MOD Title: Dice MOD
MOD Description: A MOD to add a system of persistent dice rolls to your forum, in the form of a BBCode tag.
MOD Version: 0.4

MOD Download: http://mtg.freeunixhost.com/dice.zip
My provider hates the referrer header, so copy-paste the url into the address bar. Clicking the link won't work.

Demo Board: None (yet!)

Instructions:

Dice rolls are stored in the database according to the type of what contains it (post or private message), the container's id, the number of sides, and the index within the text. This ensures that editing the post does not change a roll. Of course, there are still ways around it (such as deleting your post and retyping it), but for the most part, this should be more than enough to force people to stay honest.

Syntax of [dice] tag:

Hoo boy, this is a doozy.
A [dice] tag may contain any number of comma-delimited rolls. Each roll contains the number of sides to the die, optionally preceded by another number and a 'd' to roll that many (as in "4d6" to roll four six-sided dice). You may also follow the number with a percent sign and a number to drop that many of low dice (so if you write "7d8%2", the result is the sum of seven eight-sided dice, but not counting the lowest two). After the drop specifier, and number of modifiers may be added. A modifier is any character among "+-/*^<>" followed by any number (floating point numbers are supported). Each modifier is evaluated in the order specified. For +, -, * and /, the appropriate mathematical operation is applied to the two numbers (with the current total being the number on. For ^, the current total is raised to the power of the value afterward (the absolute value is taken first, be careful). < makes it so that the total is lowered until equal to or less than the value given; > does just the opposite. Whitespace, including newlines, can occur anywhere except inside a number.

You can also name a dice block by writing the name of the block after an = sign in the opening tag. Individual rolls can be named by putting the name of the roll before the roll's syntax, separated by a colon. Whitespace between the first non-whitespace character of the name and the colon will be retained, except that newlines will be replaced by spaces.

Examples:
To roll 4d6, dropping the lowest die each time, minimum of 6 (let's say) for the six abilities in D&D, you might write [dice=Ability Scores]Str:4d6%1>6,Dex:4d6%1>6,Con:4d6%1>6,Int:4d6%1>6,Wis:4d6%1>6,Cha:4d6%1>6[/dice]
To roll a 100-sided die, double it, and take the square root, write [dice]100*2^0.5[/dice] (note the use of a fractional exponent).


Newest version:
  • Stable release, RC1
  • Fixed all bugs
Todo:
  • Comment the regexes
  • Add a modifier to raise a number to the exponent of the sum (so, for instance get the nth mersenne number)
  • Add a modifier to get a 'score' based on number above a threshold (for instance, how many are above 7?)
  • Add a modifier to roll again if you got above a certain score (for instance, reroll and add to the total if you rolled the highest possible)
  • Add some other modifiers
  • Add an FAQ entry
  • Add automation script
Last edited by Sam on Fri Aug 06, 2010 12:28 am, edited 21 times in total.
Reason: Marked mod as abandoned, if the original poster wishes to continue this, please PM any MOD team member to have it unlocked.

Mateobaka
Registered User
Posts: 15
Joined: Wed May 23, 2007 11:12 pm

Re: [BETA] Dice MOD

Post by Mateobaka » Fri May 25, 2007 10:48 am

Looks good, I'll give it a whirl in the morning. :ugeek:

Flame of Darkness
Registered User
Posts: 11
Joined: Sun May 27, 2007 12:56 pm

Re: [BETA] Dice MOD

Post by Flame of Darkness » Sun May 27, 2007 2:54 pm

The download link sends me to a strange page where I can't see any downloads.
A rose by any other name would still have thorns...

coppro
Registered User
Posts: 84
Joined: Wed May 16, 2007 3:10 am

Re: [BETA] Dice MOD

Post by coppro » Sun May 27, 2007 7:08 pm

:(

Try copy-pasting the URL. I've had trouble linking to this provider before.

Flame of Darkness
Registered User
Posts: 11
Joined: Sun May 27, 2007 12:56 pm

Re: [BETA] Dice MOD

Post by Flame of Darkness » Mon May 28, 2007 3:36 pm

Thanks; that works now. I'll test it out in a short while.
A rose by any other name would still have thorns...

User avatar
MasterZ
Registered User
Posts: 712
Joined: Wed Sep 24, 2003 5:33 am
Contact:

Re: [BETA] Dice MOD

Post by MasterZ » Mon May 28, 2007 3:41 pm

What is the purpose of the dice rolls? What can you do with it?

coppro
Registered User
Posts: 84
Joined: Wed May 16, 2007 3:10 am

Re: [BETA] Dice MOD

Post by coppro » Mon May 28, 2007 4:20 pm

Keep people honest while playing games, for one.

coppro
Registered User
Posts: 84
Joined: Wed May 16, 2007 3:10 am

Re: [BETA] Dice MOD

Post by coppro » Tue May 29, 2007 1:52 am

New version out. This version is significantly more optimized.

lcq
Registered User
Posts: 4
Joined: Tue May 29, 2007 2:29 am

Re: [BETA] Dice MOD

Post by lcq » Thu May 31, 2007 1:54 am

Small typo on viewtopic.php

Code: Select all

if (has_dice($row['bbcode_bitfield']))
{
	$dice->new dice('post', $row['post_id']);
	$dice->parse($message);
}
Shoud've been

Code: Select all

if (has_dice($row['bbcode_bitfield']))
{
	$dice = new dice('post', $row['post_id']);
	$dice->parse($message)
}
However, MOD won't work with PHP 4, due to your use of foreach on dice.php.
See http://www.php.net/manual/en/control-st ... oreach.php for more info.

Perhaps you could rewrite the code to make it PHP 4 compatible? Anyway, only a suggestion for the next release.

Thank you

coppro
Registered User
Posts: 84
Joined: Wed May 16, 2007 3:10 am

Re: [BETA] Dice MOD

Post by coppro » Fri Jun 01, 2007 1:42 am

Thanks!

I don't even know what that array reference was for, anyway :lol:

New version uploaded

henningh
Registered User
Posts: 1
Joined: Tue Jun 12, 2007 12:24 am

Re: [BETA] Dice MOD

Post by henningh » Tue Jun 12, 2007 12:31 am

*I found the problem so ignore the error message*
I have installed your mod but I'm running into some problems getting everything working right. After getting the constants file sorted out I'm now getting the following error.

Code: Select all

Parse error: syntax error, unexpected '&', expecting T_VARIABLE or '$' in /home/httpd/vhosts/randomfactor.net/httpdocs/phpBB3/includes/dice.php on line 187
I'm no php wiz so I'm lost on how to figure out whats going wrong here.

One suggestion I have would be to note in the instructions that until you complete the last step with getting the bb number for the dice code there will be php parse errors. Perhaps changing the {NUM} to something more like CHANGEME would help.

Otherwise it looks like just the thing our group needs to conduct an online game.

--Henning

coppro
Registered User
Posts: 84
Joined: Wed May 16, 2007 3:10 am

Re: [BETA] Dice MOD

Post by coppro » Tue Jun 12, 2007 10:57 pm

Thanks for that, as it seems I hadn't fixed a bug that I thought I'd fixed. I also changed the {NUM} to be more descriptive.

CancelloCornorosso
Registered User
Posts: 19
Joined: Fri Aug 18, 2006 7:40 pm

Re: [BETA] Dice MOD

Post by CancelloCornorosso » Wed Jun 13, 2007 11:37 pm

Thanks coppro, this mod is something I was really looking forward to!

however, what do you think about using a syntax like [dice]3d6[/dice]. wouldn't it be simpler?

do you know about the old dice mod for phpbb 2.x? It's really nice and you can do stuff like [dice="foo test"]3d6+5[/dice], I guess you could reuse much of the code.

coppro
Registered User
Posts: 84
Joined: Wed May 16, 2007 3:10 am

Re: [BETA] Dice MOD

Post by coppro » Thu Jun 14, 2007 3:39 pm

I tried but couldn't find a similar MOD for 2.x. Could you point me to it?

XdY is a very good idea. I also hadn't thought of using the "[dice=whatever]". Both of those shouldn't be too hard.

I've uploaded a new version without the unneeded query (it just adds some acl data). If anyone downloaded the most recent version before this post and ran the second query entry, you can leave it in. It will be needed in the future.

EDIT: It seems my provider is down for the moment. I'll upload it sometime later.

TRICHES.FR
Registered User
Posts: 75
Joined: Sat Jun 09, 2007 5:23 pm

Re: [BETA] Dice MOD

Post by TRICHES.FR » Thu Jun 14, 2007 4:01 pm

just a question ... what is the point of a dice roll ? ive seen it before for game forums but what else ?

Locked

Return to “[3.0.x] Abandoned MODs”

Who is online

Users browsing this forum: Exabot [Bot] and 7 guests

cron