Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > vBulletin 3.5 > vBulletin 3.5 Add-ons
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
Dice Roller Hack [BBCode] Details »»
Dice Roller Hack [BBCode]
Version: 1.00, by Eikinskjaldi Eikinskjaldi is offline
Developer Last Online: Jul 2023 Show Printable Version Email this Page

Version: 3.5.4 Rating:
Released: 04-24-2006 Last Update: 05-29-2006 Installs: 51
DB Changes Uses Plugins Template Edits
Additional Files  
No support by the author.

Dice Roller Hack [BBCode]
RPG Dice is currently a updated version
Another updated version

Note: Updated package includes only the correct XML.

This hack is a port of: Dice Roll for vB3 and permissions was given to port by the following statement.

Quote:
Info for hackers:
You may modify, improve, upgrade, redistribute this hack, include it
in another hack or yours or translate it provided you do it free of
charge and you distribute it in www.vbulletin.org at least, there is no
need to pm me asking for permission.
This hack rolls a Graphic based dice roll in your post and features multiple dice rolls per post. The images are fully editable by those who know how and I must agree that I very much think they need an overhaul, so go for it.

The basic bbcode format is:
[dice=X]Y[/dice]

X - The number of dice to roll, This cannot be larger then 5 currently, this may change later with demand.
Y - The number of sides on the dice.

so [dice=1]6[/dice] Roll's 1, 6 sided dice.

The only limit that I have noticed so far is that dice will not apear correctly when rolled from the create thread editor. I am unsure as to why this is still and am working on this issue. However aside from this it is working as need be. This hack is mainly useful to Game websites that require dice rollers for gambling or roleplaying games. It can add an element of fun to a forum and is adapatable to most dice require situations.

If enough demand is displayed I will work on removing the 5 roll limit or making it larger. The current maximum sides one can roll is 30.

If you enjoy this hack or have it installed, then please click the install button so that you can remain informed when updates occur.

As the original author said, You do not need to ask permission to update or do anything to this hack and can redistribute it if you feel you have made a great contribution to it.

If someone does make new dice images and wishes to have them as part of the package then either post here or PM me and I will get them in there with full rights going to the sender for the images.

Updates:
  • 04/29/06
    • Added new dice images which where provided by Rukbat.

This hack was requested from: https://vborg.vbsupport.ru/showthread.php?t=97775

-Eikinskjaldi-

Original Screenshots:
https://vborg.vbsupport.ru/attachmen...3&d=1078098688
https://vborg.vbsupport.ru/attachmen...4&d=1078098702

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.

Comments
  #82  
Old 05-29-2006, 05:57 PM
cclaerhout's Avatar
cclaerhout cclaerhout is offline
 
Join Date: Aug 2004
Location: Paris (France)
Posts: 448
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I'm waiting for you Since your last post, i've imagined a new user interface easier to code if you manage to do what you're trying.

The code will be something like this :
Code:
<fieldset style="width:140px;">
<legend style="font-size: 14px;color:black;font-weight:bold;">Dice menu</legend>
<span style="font-size: 12px;color:black;font-weight:bold;">D04 : </span>
<input style="font-size: 9px; width:20px" type="submit" name="Submit" value="x1"><input style="font-size: 9px; width:20px" type="submit" name="Submit" value="x2"><input style="font-size: 9px; width:20px" type="submit" name="Submit" value="x3"><input style="font-size: 9px; width:20px" type="submit" name="Submit" value="x4"><input style="font-size: 9px; width:20px" type="submit" name="Submit" value="x5">
<br />
<span style="font-size: 12px;color:black;font-weight:bold;">D06 : </span>
<input style="font-size: 9px; width:20px" type="submit" name="Submit" value="x1"><input style="font-size: 9px; width:20px" type="submit" name="Submit" value="x2"><input style="font-size: 9px; width:20px" type="submit" name="Submit" value="x3"><input style="font-size: 9px; width:20px" type="submit" name="Submit" value="x4"><input style="font-size: 9px; width:20px" type="submit" name="Submit" value="x5">
<br />
<span style="font-size: 12px;color:black;font-weight:bold;">D08 : </span>
<input style="font-size: 9px; width:20px" type="submit" name="Submit" value="x1"><input style="font-size: 9px; width:20px" type="submit" name="Submit" value="x2"><input style="font-size: 9px; width:20px" type="submit" name="Submit" value="x3"><input style="font-size: 9px; width:20px" type="submit" name="Submit" value="x4"><input style="font-size: 9px; width:20px" type="submit" name="Submit" value="x5">
<br />
<span style="font-size: 12px;color:black;font-weight:bold;">D10 : </span>
<input style="font-size: 9px; width:20px" type="submit" name="Submit" value="x1"><input style="font-size: 9px; width:20px" type="submit" name="Submit" value="x2"><input style="font-size: 9px; width:20px" type="submit" name="Submit" value="x3"><input style="font-size: 9px; width:20px" type="submit" name="Submit" value="x4"><input style="font-size: 9px; width:20px" type="submit" name="Submit" value="x5">
<br />
<span style="font-size: 12px;color:black;font-weight:bold;">D12 : </span>
<input style="font-size: 9px; width:20px" type="submit" name="Submit" value="x1"><input style="font-size: 9px; width:20px" type="submit" name="Submit" value="x2"><input style="font-size: 9px; width:20px" type="submit" name="Submit" value="x3"><input style="font-size: 9px; width:20px" type="submit" name="Submit" value="x4"><input style="font-size: 9px; width:20px" type="submit" name="Submit" value="x5">
<br />
<span style="font-size: 12px;color:black;font-weight:bold;">D20 : </span>
<input style="font-size: 9px; width:20px" type="submit" name="Submit" value="x1"><input style="font-size: 9px; width:20px" type="submit" name="Submit" value="x2"><input style="font-size: 9px; width:20px" type="submit" name="Submit" value="x3"><input style="font-size: 9px; width:20px" type="submit" name="Submit" value="x4"><input style="font-size: 9px; width:20px" type="submit" name="Submit" value="x5">
<br />
</fieldset>
Reply With Quote
  #83  
Old 05-29-2006, 07:57 PM
Eq4bits Eq4bits is offline
 
Join Date: May 2006
Posts: 468
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Emmy2
I'm not a coder but I think I did it! I've created code that will add an image button or a regular button to the quick reply and regular editors that when clicked by user automatically inserts the text for one pre-defined dice roll. It doesn't have a drop-down menu for multiple options, but hey it's a start! And maybe with the base code in place someone can look at it and see how to add a menu. All I did was research on google and played with some code I found and kept testing and this one finally worked.

I will post the code late tonight when I get home from work...I have been working on this all day.

:banana:
Emmy, that can be done via the adminCP bbcode manager and what i was playing with. I stuck a small gif of a blank die in the images/editor file and then in adminCP>BBcode did the 'add new bbcode' thing. I could get it to give me a return of
Code:
[DICE][/DICE]
into a posting window, but even after sticking in '6' between the two tags when I submitted it wouldn't show the dice in the post... just the 'total points'.

Looking forward to seeing your fix around it.
Reply With Quote
  #84  
Old 05-29-2006, 08:08 PM
cclaerhout's Avatar
cclaerhout cclaerhout is offline
 
Join Date: Aug 2004
Location: Paris (France)
Posts: 448
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Eq4bits
Emmy, that can be done via the adminCP bbcode manager and what i was playing with. I stuck a small gif of a blank die in the images/editor file and then in adminCP>BBcode did the 'add new bbcode' thing. I could get it to give me a return of
Code:
[DICE][/DICE]
into a posting window, but even after sticking in '6' between the two tags when I submitted it wouldn't show the dice in the post... just the 'total points'.

Looking forward to seeing your fix around it.

This method has two problems :
1)you have to enter the number of faces.
2)you can't specify the number of dice.
Reply With Quote
  #85  
Old 05-29-2006, 10:05 PM
Eq4bits Eq4bits is offline
 
Join Date: May 2006
Posts: 468
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

yeah I know, is why my eyes started bleeding trying to make it do one or the other and had to quite
Reply With Quote
  #86  
Old 05-30-2006, 01:24 AM
Emmy2 Emmy2 is offline
 
Join Date: Jan 2004
Posts: 83
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

vb Coders...

Okay, here is the code I worked out to add a button to the editor to automatically insert a dice roll.

Remember I’m not a coder, so use this at your own risk. I just kept fiddling with it until it worked. I don’t know the possibility of any negative consequences of the script, so if there are flaws I’m not responsible! I also have never posted code or instructions before, so I hope my directions are coherent.

I've included code for three different button types....a simple text link, a text button, and an image button. Choose the one you prefer. The two best are the text link and the image button. The text button is a little buggy, but still works.

You need to install the script in two places, so that a button shows up on both the quick reply editor and the regular editor. So find these templates:

editor_toolbar_on
showthread_quickreply

Into each template you will add a bit of code to make a button. To find the places to insert the code....

In editor_toolbar_on look for:
Code:
$vBeditTemplate[extrabuttons]
In showthread_quickreply look for:
Code:
<if condition="!is_browser('opera')">

ABOVE each of those lines add ONE of the following codes to make your button:

For a text button on the editor toolbar:
Code:
<td><input type="button" value="Roll 3 Dice" onclick="document.getElementById('{$editorid}_textarea').value += '[dice=3]6[/dice]';"></a></td>
For a text link on the editor toolbar:
Code:
<td><a href="javascript:void(0);" onclick="document.getElementById('{$editorid}_textarea').value += '[dice=2]6[/dice]';
return false;">Roll 2 Dice</a></td>
For an image button on the editor toolbar:
Code:
<td><a href="javascript:void(0);"><img src="http://www.yoursite.com/diceimage.gif" title="Roll 5 Dice"
onclick="document.getElementById('{$editorid}_textarea').value += '[dice=5]6[/dice]';"></a></td>
Be sure to change the variables to suit your site....ie. the image url to your own image, and the variables of the dice roll to what you want. (an example is [dice=5]6[/dice] but you can create whatever roll you want), and/or the name of the text button to what you want.

Theoretically you can add as many buttons for as many different rolls as you want. However, I know that is too cumbersome. Ideally some sort of option menu would be ideal, like for smilies or fonts. But I don’t know how to code that. Maybe someone else can help now that I've worked out the basic code.

Btw, this script could be used for more than just dice roll. It could be used for any other complex bbcode string that you want to preset, or even for full sentences (“Your post was very helpful to me.”). Just anything that would save the user some keystrokes (as long as there are no quotes in the text string, I think that would mess things up).
Reply With Quote
  #87  
Old 05-30-2006, 05:14 AM
Eq4bits Eq4bits is offline
 
Join Date: May 2006
Posts: 468
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Emmy2
In showthread_quickreply look for:
Code:
<div>$vBeditTemplate[extrabuttons]</div>
Emmy,
am using ver. 3.5.4 I don't have that code in my showthread_quickreply template... it's never been changed since the upgrade. Any suggestions as to where to add this?
Reply With Quote
  #88  
Old 05-30-2006, 09:31 AM
Emmy2 Emmy2 is offline
 
Join Date: Jan 2004
Posts: 83
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Oops, sorry, that is my fault. My showthread_quickreply is already hacked and that must be some additional code I have in mine.

Try putting it just before this line:

Code:
<if condition="!is_browser('opera')">
I can't test it, but I think it goes there.
Reply With Quote
  #89  
Old 05-30-2006, 09:33 AM
cclaerhout's Avatar
cclaerhout cclaerhout is offline
 
Join Date: Aug 2004
Location: Paris (France)
Posts: 448
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You dit it

I've finished to integrate your code. I'm trying to improve user interface now.
Reply With Quote
  #90  
Old 05-30-2006, 02:28 PM
Zowners Zowners is offline
 
Join Date: Dec 2005
Posts: 318
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Okay I did what Emmy said and that worked perfectly.

For those who only see the "[dice=6]6[/dice]" and no images, be sure to UNINSTALL the 1_0 xml file before installing the 0_1 file. I believe the reason I had so many problems was that instead of unintalling I kept overwriting.
Reply With Quote
  #91  
Old 05-30-2006, 07:30 PM
Eikinskjaldi's Avatar
Eikinskjaldi Eikinskjaldi is offline
 
Join Date: Feb 2006
Location: Hell, never looked better
Posts: 572
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Also, for those who dont want a million buttons you can use this instead:
Code:
<script type="text/javascript">
function dropDownDice(obj){
if(obj.value != ''){ 
    var data = obj.value;
    var indx = data.indexOf(';');
    var diceToRoll = data.substr(0,indx);
    var faces = data.substr(indx+1);
    document.getElementById('{$editorid}_textarea').value += '[dice='+diceToRoll+']'+faces+'[/dice]';
}
}
</script>

<td><select onChange="dropDownDice(this);">
<option></option>
<option value="1;6">1d6</option>
<option value="2;6">2d6</option>
<option value="3;6">3d6</option>
<option value="4;6">4d6</option>
<option value="5;6">5d6</option>
<option value="6;6">6d6</option>
</select></td>
Place it where you would place the other ones, just above the:
Code:
<if condition="!is_browser('opera')">
Should help with those who dont want to clutter there editor.

NOTE: These do not work if you have WYSIWIG turned on.

To add a new dice just add:
Code:
<option value="Number of dice to roll;Number of faces">Descriptor</option>
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 02:25 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.05000 seconds
  • Memory Usage 2,336KB
  • Queries Executed 25 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (13)bbcode_code
  • (4)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (6)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (1)pagenav_pagelinkrel
  • (11)post_thanks_box
  • (11)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (11)post_thanks_postbit_info
  • (10)postbit
  • (11)postbit_onlinestatus
  • (11)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete