SMFHacks.com

Modifications/Themes => General SMF Forum => Topic started by: halbarad on March 08, 2007, 10:09:22 am

Title: Need help working on a mod
Post by: halbarad on March 08, 2007, 10:09:22 am
Hi

I am quite new to SMF and need some help with a mod I want to do. I am running a forum which will include Roleplaying and as part of that I need to make a dice roller, I want to do this as an additional option when posting a reply to a topic, however I don't know where all the options for this are set, nor where I should really code the rolling of the dice. I think I would also need to change how the posts are shown to check if the user rolled a dice and display the result.

Does anyone have any ideas on how I could do this, or where I should look to start coding the dice rolling options.

Thank you in advance.
Title: Re: Need help working on a mod
Post by: SBB on March 09, 2007, 02:38:28 am
I'd almost go after posts.php (or, subs-posts.php).

In the actual createpost function, just prior to the insert, do a regex for some pseudo BBCode you're about to invent. Something akin to
[roll=12] or whatever you need. In this case, a 12 sided. I'd suggest just prior to the insert, as you want to wait for the actual post to be created; you do NOT want this evaluated during a preview :)

I suspect the regex would be something akin to

\[roll=(%d{1,2})\]
...to support up to 99 sides.

Just prior to the insert, if at least one [roll=] is present, append some linefeeds to the message.
Then for each [roll=] in the post, generate the roll and append it to the message.

To validate that the rolls are legit... a reader merely proves that one or more [roll=] are present in the post, which means the legit rolls will be on the last line or something. (You will need to segregate the roll text from the user message, heh. Otherwise, I'd simply omit the [roll] and supply my own at the end of my message. Wow! I won again!)

Sounds like a fun project!
- SBB
Title: Re: Need help working on a mod
Post by: halbarad on March 09, 2007, 04:19:07 am
Thanks for the help. I am not entirely sure how I would do some things (like segregating the roll text from the rest of the message) but I will look into it and see what I can do.

Thanks for the help.