Welcome Guest [Log In] [Register]
We hope you enjoy your visit.

You're currently viewing our forum as a guest. This means you are limited to certain areas of the board and there are some features you can't use. If you join our community, you'll be able to access member-only sections, and use many member-only features such as customizing your profile, sending personal messages, and voting in polls. Registration is simple, fast, and completely free.


Join our community!


If you're already a member please log in to your account to access all of our features:

Username:   Password:
Add Reply
Dice Rolling Code
Topic Started: Feb 10 2010, 12:23 PM (15,624 Views)
Reid
Member Avatar
una trappola!
[ *  *  *  *  *  *  * ]
What it does: adds a new BBCode, [roll], allowing your members to roll some dynamic dice, for sure.

How to use it: When you add a new post, simply use the following format: [roll]1d12+1[/roll]

There is also a BBCode button added to the posting page.

Format explained

The format is something like so: [roll](NUMBER OF TIMES)d(NUMBER OF SIDES)+(EXCESS)[/roll]

It can also handle multiple dice being rolled, even without excess. You can also omit the number in front of the d, which will be assumed to be 1. The D can be capital, too, like 3D14.

example: [roll]3d5+5+4d6+3[/roll] or [roll]3d5+4d6+1[/roll]

Security features: While these will be no hindrance to anyone that knows their way around the web significantly, the script does have some features in place to prevent most cheaters. Firstly, once a post has a roll in it, it is no longer editable. If a person attempts to copy the result tag into a new post, it will ask him not to cheat and prevent the form from submitting. If a person copies the URL of an edit to a post, then does a roll, and attempts to paste the URL and change the result, it will ask him not to cheat and prevent the edit.

Also, after the roll has been submitted, the browser will parse the result tag and display it in a friendly format. Simply hover over the result to get the dice the user used to roll. You can also click on the result for a very detailed overview of each die and how the results fell as well as any excess.

Works in: Every browser, as far as I know.

How to install: Put the following in Admin CP -> Board Template -> Below the Board:
Code:
 
<script type='text/javascript' src='http://z3.ifrm.com/313/104/0/p246374/dice_roll.js?c=3'></script>
Enjoy. :D
Edited by Reid, Dec 18 2010, 02:38 PM.
Offline Profile Quote Post Goto Top
 
maytads
Member Avatar
Rich Girl~ Nararananaranarana~
[ *  * ]
Thank you very much, it's great. You are great
Offline Profile Quote Post Goto Top
 
Deleted User
Deleted User

Thank you. So much!

The previous dice rolling code I used on my site had an annoying option box that showed in every post, and it was easy to cheat with (frankly, it was easier just to type what you wanted in).

This code is exactly what wanted! It's absolutely perfect. Thanks for sharing and developing it!
Quote Post Goto Top
 
Reid
Member Avatar
una trappola!
[ *  *  *  *  *  *  * ]
Update: Admins may now edit posts with dice rolls in them
Offline Profile Quote Post Goto Top
 
maytads
Member Avatar
Rich Girl~ Nararananaranarana~
[ *  * ]
Great thanks for the update n.n
Offline Profile Quote Post Goto Top
 
itachi4ever
Member
[ * ]
Whoa OwO

Thank you very much >w<
Offline Profile Quote Post Goto Top
 
Reid
Member Avatar
una trappola!
[ *  *  *  *  *  *  * ]
Green Lantern
May 2 2010, 12:18 PM
Update: Admins may now edit posts with dice rolls in them
Fixed a bug concerning this, sorry it took so long to get around to.
Offline Profile Quote Post Goto Top
 
Vegito1
Member Avatar
Vegito is number #1
[ *  * ]
and is there a way that whenever anyone clicks the roll button in the BBCode list, it automatically gets the following format with the roll tags.

[roll]1d10[/roll]
Offline Profile Quote Post Goto Top
 
Reid
Member Avatar
una trappola!
[ *  *  *  *  *  *  * ]
Use the following code in your board template instead:
Code:
 
<script type='text/javascript' src='http://z3.ifrm.com/313/104/0/p246374/dice_roll.js?c=2'></script>
<script type='text/javascript'>
insert_roll = function () {
var b = $('textarea[name=post]');
b.val(b.val() + '[roll]1d10[/roll]');
};
</script>
Offline Profile Quote Post Goto Top
 
Vegito1
Member Avatar
Vegito is number #1
[ *  * ]
thanks
Offline Profile Quote Post Goto Top
 
Vegito1
Member Avatar
Vegito is number #1
[ *  * ]
Green Lantern Can you change the code so whenever i (Admin Only) bring the mouse cursor over a number that came by the Dice Roll code, it tells me what format was used to get this number to prevent cheating.


EDIT: oh sorry forgot that this function was already in the Dice Rolls security features.
Green Lantern can you edit the code so instead of the option Roll in the BBCode list, i want it to be Roll Dice.
Edited by Vegito1, Jun 12 2010, 02:36 AM.
Offline Profile Quote Post Goto Top
 
Reid
Member Avatar
una trappola!
[ *  *  *  *  *  *  * ]
Code:
 
<script type='text/javascript' src='http://z3.ifrm.com/313/104/0/p246374/dice_roll.js?c=2'></script>
<script type='text/javascript'>
insert_roll = function () {
var b = $('textarea[name=post]');
b.val(b.val() + '[roll]1d10[/roll]');
};
$('#c_bbcode button:contains(Roll)').html("Roll Dice");
</script>
Offline Profile Quote Post Goto Top
 
Vegito1
Member Avatar
Vegito is number #1
[ *  * ]
thanks
Offline Profile Quote Post Goto Top
 
Vegito1
Member Avatar
Vegito is number #1
[ *  * ]
If i use the following format does it mean it can get numbers up to 5 except 1.

[roll]1d5+1[/roll]
Offline Profile Quote Post Goto Top
 
Reid
Member Avatar
una trappola!
[ *  *  *  *  *  *  * ]
You are correct, because rolling 0 is not built into the script. Something I should probably fix.
Offline Profile Quote Post Goto Top
 
1 user reading this topic (1 Guest and 0 Anonymous)
Go to Next Page
« Previous Topic · Codes & Modifications · Next Topic »
Add Reply