[How To] Dice Roller!
Posted
#4060
(In Topic #807)
Standard member

Dice Roller for RP communities
Want to make a RP forum community and allow dice rolls in your forum posts and chats? Or perhaps you just want to have a fun dice number guessing game? Then read on, for this tutorial will help you to have a dice roller in your Composr/Coversr powered site!NOTICE: This requires changing / replacing php files. Please make a backup before continuing. We are not responsible if this code causes your hamsters to mutate and your computers to randomly melt.
Now that the important disclaimer is out of the way, lets get started. This change to your site will allow you to have a dice roller that works in forum posts AND chat / shoutbox messages - giving you a fair and useful way to run stat-based rp's where dice rolls are needed.
To make this happen first we need to replace sources/comcode_renderer.php
Replace it with the following file.
comcode_renderer.php
Please Note: The changes to comcode_renderer.php are being implemented in the next patch release. It is likely that you will not need to update/replace your file with this one. Check first to see if you can complete the next steps and have a working dice roller before replacing comcode_renderer.php.
Next you will need to add a file. First you may need to create the folder "comcode" under "sources_custom/hooks/systems/" and enter that folder so that you are in "sources_custom/hooks/systems/comcode/".
You will upload the attached roller.php file to that folder/location.
roller.php
Once those files are changed go ahead and clear your caches and refresh your site. You should now have a working dice roller!
In order to use the dice roller, you will use the following syntax:
Code
[roller="some_id"]3d10[/roller]
The "some_id" is important as it is what saves the dice roll so that the number doesn't change when the page is refreshed. It must be different with each use of the roller tag.
The 3 is the number of dice you want rolled.
The 10 iis how many sides of dice you want. This is basically how many numbers it will randomize.
The result will have each dice rolled seperated by "&".
If you want a simple regular d6, you could use either of the following for example:
Code
[roller="d6"]1d6[/roller]
[roller="d6 2"]1,2,3,4,5,6[/roller]
Here's a screenshot of it working!
Special thanks to Chris Graham for making this possible!
Like ocPortal? Want to thank Chris and gang somehow? Then help out in the chat room! It really needs your help! Just open it in a tab everytime you open your web browser, and when you hear a "ding", check it out!
"Those who want help should first be willing to give help."
1 guest and 0 members have just viewed this.

