News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Dice roll mod ... again.

Started by Adin, February 02, 2005, 08:49:07 AM

Previous topic - Next topic

shanks

To figure in the exploding rolls without overly bloating the code may require a bit of a rewrite. I'll be having another crack at it tomorrow.

URPG, once I've got this one sorted I'll have a look at your request and then sorting out automatic crit rolling.

With regards to syntax, and I assume you specifically mean what the generated rolling code (:rollgen blah,blah,etc:) means, it is under review and I am looking to compact it considerably and/or change how certain things work to make the roller even more versatile than it currently is.

TechnoDragon

Awesome...You have no idea how popular this mod will be once this gets figured out...I know at least 2 dozen rpg boards that will jump on this...maybe more.
Don't tell me to get into shape...I have a shape...It is round!


shanks

#102
Right!

For the forseeable future this is the last modification to post.php:

In post.php, find:
preparsecode($_POST['message']);

Add after:

include_once 'RPG.php';
$_POST['message'] = preg_replace('~:dice (\d+)d(\d+)(\D*?)(\d*?):~ei', "dice('\$1', '\$2', '\$3', '\$4')", $_POST['message']);
$_POST['message'] = preg_replace('~:stats (\d+)d(\d+)(\D*?)(\d*?),(\D+),(\d+):~ei', "statroll('\$1', '\$2', '\$3', '\$4', '\$5', '\$6')", $_POST['message']);
$_POST['message'] = preg_replace('~:rollgen (.*?):~ei', "rollgen('\$1')", $_POST['message']);


For those who have yet to see, but unchanged for those who have already done so:

In post.template.php, find:

global $context, $settings, $options, $txt, $modSettings;


Replace with:

global $context, $settings, $options, $txt, $modSettings, $scripturl;


...and find

// Finally the most important bit - the actual text box to write in!

Add before:

// Enter link to the roller!
echo '
<tr>
<td valign="top" align="right"></td>
<td><a href="'.$scripturl.'?action=rpg" onclick="return reqWin(this.href,420,350)">Dice Roller Code Generator</a></td>
</tr>';


And then the hardest part! Upload the RPG.php file into the Sources folder.

The roll generator can then be loaded in a pop up window by clicking the link below the smilies in the "Post Reply" window. Once you have chosen the parameters for the roll paste the generated code into the text box and submit your post.

Be wary though! You can't edit the post without ruining the output of the roller.

shanks

I would also like to stress that, while I do test the roller, things can pass me by. If you spot something that is not working properly, or, even, not even necessary, please don't hesistate to say so. I can only improve the roller based on your feedback!  ;)

TechnoDragon

I have just tested it....the results......


There were a few erros...you need a global call for the functions...I kept getting an undefined index error and when i put the global call:
global $scripturl, $context, $settings;

they went away...

Also, i am getting an undefined offset error 1-8...i believe these are from where the roller decides what values you input go where but I cannot find the function in RPG.php that it calls from or I would fix it for you.  I would assume (from other topics i have read) that they must be in a format like $1, $2, etc...

the roller still works perfectly for shadowrun rolls...
Don't tell me to get into shape...I have a shape...It is round!


Dresdan

Can't thank you enough for this mod.  I just added it the other day and it's a big hit in my forum.  Everyone likes the versitility of the script.  I run a role playing forum with all different genres and types of roleplaying and this die roller will accomodate several different gaming systems.  Well done, and again thank you.  :D

shanks

technodragon73, Are you sure that you're using the absolute latest RPG.php and using the correct edits for post.php? I am not getting any of the errors that you mention...

TechnoDragon

hmmm...must have been a momentary glitch...it is not doing it now...but i did notice something when i looked closer...I added a modifier to the roll and it did not take that into account when it rolled for successes.

Rolling 8d6, exploding any results at or above 6:
3, 4, (6+1)7, (6+4)10, 3, 2, 2, 3 =
There were 0 successes when rolling each die against a target of 11.

that should have a +3 modifier
Don't tell me to get into shape...I have a shape...It is round!


shanks

Could you post the rollgen code used, please?

TechnoDragon

Don't tell me to get into shape...I have a shape...It is round!


URPG

Could anyone summarize what files i have to get? Or even better: Post the files already modificated so i simply need to replace mine? To be honest i am a bit confused trying to find out what the latest version is and how to install it.

And an explanation of the syntax final would be cool too...

shanks

Quote from: URPG on February 26, 2006, 04:24:50 PM
Could anyone summarize what files i have to get? Or even better: Post the files already modificated so i simply need to replace mine? To be honest i am a bit confused trying to find out what the latest version is and how to install it.

Well, I have no idea what version of SMF you are using or what other modifications you may have, so, it's difficult to do that.

Go back one page on this thread and you will see the instructions you need to follow. It is fairly self evident that you will always need whatever is instructed in the latest of my posts on the subject. And as the current latest post clearly says, there are no forseeable changes to post.php or post.template.php in the near future, so as long as you have what is there you are ok.

QuoteAnd an explanation of the syntax final would be cool too...

I have already made reference to this.

Quote
With regards to syntax, and I assume you specifically mean what the generated rolling code (:rollgen blah,blah,etc:) means, it is under review and I am looking to compact it considerably and/or change how certain things work to make the roller even more versatile than it currently is.

If you neither confirm nor deny what I am assuming you mean then there is nothing that I can do to help you here. Regardless, again, like the post says, how the roller works is subject to change, so if this is what you are after I am not going to pointlessly provide until I know the direction the roller is going in. All that aside the only syntax that you need is generated by the popup, rendering discussion of unfinalised syntax a waste of time.

URPG

#112
As i said before it's an out of the box SMF installation + MKP (portal software). I am not sure but i don't think the later one modified posts.php (or whatever else is needed).   ::)

I was just wondering what instructions to follow and would have liked to spare me the time to do as the last instructions said, then read the bugfixes on it, and re-edit, etc.  :'(

Guess i will wait with field-testing until you sorted out your syntax-trouble? Would you like sugestions on syntax? I am rather good at simpliefying and summarizing things... Just detail the "even better" method you mentioned and i see if i can help?

sr_dragon

as terrible as it sounds, I've a feeling that I'm either not paying attention or just not seeing the answer.

Is the only way to run this roller via "roll" commands in the posted message or is a popup window in which you put in your rolls and such?

also, I've got a diceroller working but I could use a bit of help integrating it into SMF and adding a couple extra features, if it's something that anyone could lend a hand with I'd be greatly appreciative.

TechnoDragon

sr_Dragon...

In answer to your question, Both...there are commands to do basic roll functions such as dice (this command basically lets you play a game like yatzee), or stats (which will rolls stats for games like D&D)

The roll generator is a popup window that will let you choose from a variety of options and then generate the code whic you place into your post.
Don't tell me to get into shape...I have a shape...It is round!


TechnoDragon

Any word on the modifier problem?
Don't tell me to get into shape...I have a shape...It is round!


shanks

Not yet! You want the modifier applied to each roll? If so then you'll have to wait for the next revamp.... *suspense*!

URPG

Well, yes a modifier that can be applied to the total roll or to each dice would be great.

TechnoDragon

#118
Sorry I don't mean to be pestering you (if I am), just overly excited about this mod...BTW, when this is finished, I have figured out how to do packages so I can make this into one when it is finished if you would like.

Yes, the modifier (idealy) would be applied after the exploding roll and the final value applied against the target.  Perfectly you could choose to add it to each die or to the total...similar to the way you allow users to choose total of rolls, individual rolls or both at the bottom.
Don't tell me to get into shape...I have a shape...It is round!


TechnoDragon

ok...so I had some free time...I packaged this up into a mod (should work, let me know):

http://www.technodragon.net/files/rollgen.zip
Don't tell me to get into shape...I have a shape...It is round!


Advertisement: