inherit
91961
0
Jul 28, 2008 8:33:14 GMT -8
londonjohn
44
November 2006
londonjohn
|
Post by londonjohn on May 6, 2007 2:25:55 GMT -8
That's strange because it definitely works fine for me in both IE7 & FF2. John
|
|
inherit
91961
0
Jul 28, 2008 8:33:14 GMT -8
londonjohn
44
November 2006
londonjohn
|
Post by londonjohn on May 17, 2007 5:41:42 GMT -8
I spoke too soon The Dice roller has gone tits-up! It all started going wrong on the 24th of April, but I've only just noticed (Real world and all that). It's not showing any results, just this... [dice=6][dice=6][dice=6][dice=6][dice=6][dice=6][rand=9849832601112434886397863454357042254396488980946064444468480811] This is the same result on both IE7 & FF2. This is the code I have been using... <style type="text/css"> .dicebg {background-color: FFFFFF;border:solid 2px #000000;} .dicefont {background-color: FFFFFF;color: 000000; font-weight:bold;} </style> <script> //Dice Rolls In Posts v1.1
//Copyright 4-23-2007 ~Wonder //May be reposted anywhere as long as this header remains in tact
//Do you want the dice to line of horizontally(true) or vertically(false) diceAlignment=true;
//Enter URL of the image you want to appear as the dice ubbc button UBBCdiceImage="http://img100.imageshack.us/img100/6118/diceicon9rx.gif";
//Enter the default # of sides defaultSides=6;
//Enable dice in preview? true or false enablePreview=true;
rs="";mainForm=""; if(document.postForm) { mainForm=document.postForm; if(location.href.match(/action\=modifypost/)){enablePreview=true;} mainForm.color.parentNode.innerHTML+="<a href=javascript:addMult()><img src=\""+UBBCdiceImage+"\" alt=\"Insert Dice Roll\" border=\"0\"></a>"; mainForm.onsubmit=addRand; mainForm.message.value=mainForm.message.value.replace(/(\[rand\=\d+\])/ig,""); rs=RegExp.$1; if(location.href.match(/quote\=\d+/)) { mainForm.message.value=mainForm.message.value.replace(/(\[dice\=\d+\])/ig,""); rs=""; } } else if(location.href.match(/action\=display/)) { ta=document.getElementsByTagName("textarea"); if(ta.length>0 && ta[0].name=="message") { mainForm=ta[0].parentNode; mainForm.onsubmit=addRand; } }
/////////////////////// if(location.href.match(/action\=(display|pmview|recent|userrecentposts|gotopost|search|calendarview)/) || (!location.href.match(/action\=/) && document.postForm && enablePreview)) { hr=document.getElementsByTagName("hr"); for(i=0;i<hr.length;i++) { if(isset(hr[i].parentNode) && isset(hr[i].parentNode.lastChild) && isset(hr[i].parentNode.lastChild.lastChild) && hr[i].parentNode.lastChild.lastChild.nodeType!=1) { n=hr[i].parentNode.lastChild; rand=n.innerHTML.match(/\[rand\=\d+\]/); if(rand!=null) { n.innerHTML=n.innerHTML.replace(rand[0],""); rand=rand[0].replace(/[^\d]/g,""); dice=n.innerHTML.match(/\[dice\=\d+\]/ig); if(dice!=null) { for(k=0;k<dice.length;k++) { numb=parseInt(dice[k].match(/\d+/),10); roll=Math.round((parseFloat(rand.substring(k,k+2)+"."+rand.substring(k+2,rand.length))/100)*(numb-1))+1; n.innerHTML=n.innerHTML.replace(dice[k],"<table "+(diceAlignment?"style=\"display:inline\"":"")+" border=0 cellpadding=0 cellspacing=0><tr><td><table class=dicebg cellpadding=1 cellspacing=0><tr><td><center><font class=dicefont size=\"+1\"><b>"+roll+"</b><br><font size=\"1\">"+numb+" sides</font></font></center></td></tr></table></td></tr></table> "); } } } } } }
function addMult() { numb=prompt("How many dice?"); sides=prompt("How many sides per die?"); for(i=0;i<numb;i++) add("[dice="+sides+"]",""); }
function addRand() { mainForm.message.value=mainForm.message.value.replace(/(\[rand\=\d+\])/ig,""); if((rs.length==0 && mainForm.message.value.match(/(\[dice\=\d+\])/)) && (enablePreview==true || (enablePreview==false && mainForm.nextaction.value=="post"))) { mainForm.message.value+="[rand="+(Math.random()+"").replace(/0\./,"")+(Math.random()+"").replace(/0\./,"")+(Math.random()+"").replace(/0\./,"")+( Math.random()+"").replace(/0\./,"")+"]"; } else { mainForm.message.value+=rs; } disable(mainForm); }
function isset(varname){return(typeof(varname)!='undefined');} </script> Any ideas? John
|
|
inherit
91961
0
Jul 28, 2008 8:33:14 GMT -8
londonjohn
44
November 2006
londonjohn
|
Post by londonjohn on May 17, 2007 5:59:17 GMT -8
A bit more information. When previewing a post with the [dice=x] command, the dice are shown correctly, however when posting the same post, the dice disappear and the message becomes [dice=x][rand=y]. So it appears to be working but simply not able to be displayed as a post, just a preview. Hope that helps. John
[edit] (after some more testing, it appears this ability to preview, but not post a dice roll is limited to IE7. On FF2, there's no preview and the same [dice=x][rand=y] message.)
|
|
inherit
46733
0
Dec 19, 2009 9:05:41 GMT -8
Magic Carrot
All Rights Reserved
861
June 2005
magiccarrot
|
Post by Magic Carrot on May 17, 2007 7:37:08 GMT -8
I just installed this new dice version on a board with no other codes and it's working fine for me on IE7.
Just a quick question, how do you make plus dice rolls. Like D10+1.
|
|
inherit
91961
0
Jul 28, 2008 8:33:14 GMT -8
londonjohn
44
November 2006
londonjohn
|
Post by londonjohn on May 17, 2007 8:27:41 GMT -8
Hi MC, I might try removing the whisper function and see what happens, there may be a conflict. Thing is, I can't work out why it has suddenly gone wrong when it was working fine before. As for modifying a dice roll, simply add the modifier after the dice. For example for 1D6+2 use [dice=6+2]. John
|
|
inherit
91961
0
Jul 28, 2008 8:33:14 GMT -8
londonjohn
44
November 2006
londonjohn
|
Post by londonjohn on May 17, 2007 8:38:47 GMT -8
I've removed the Whisper code from that board so that the only code now occupying the footer is the above code for the dice roller. When I did that there were noticable effects: FF allowed a preview of the dice rolls Only the first post of a topic would display the dice, any subsequent dice rolls were shown as [dice=x][rand=y] When I deleted the first thread showing the dice rolls, the next post in line (which previously had been showing only the code] now showed the dice results. Again, any subsequent posts wouldn't show the dice rolls (I've just checked and it's doing the same in IE7) John
|
|
inherit
46733
0
Dec 19, 2009 9:05:41 GMT -8
Magic Carrot
All Rights Reserved
861
June 2005
magiccarrot
|
Post by Magic Carrot on May 17, 2007 8:40:55 GMT -8
Hmmmm.. it doesn't work for me. Any time I try to add a modifier it doesn't show the dice, just the tag.
~ MC
|
|
inherit
91961
0
Jul 28, 2008 8:33:14 GMT -8
londonjohn
44
November 2006
londonjohn
|
Post by londonjohn on May 17, 2007 8:43:16 GMT -8
Hmmmm.. it doesn't work for me. Any time I try to add a modifier it doesn't show the dice, just the tag. ~ MC That is strange. It's doing the same for me. I'm sure it used to allow modifications. John
|
|
inherit
46733
0
Dec 19, 2009 9:05:41 GMT -8
Magic Carrot
All Rights Reserved
861
June 2005
magiccarrot
|
Post by Magic Carrot on May 17, 2007 9:32:10 GMT -8
Bummer, because that would be a great feature. Maybe wonder changed the code?
~ MC
|
|
inherit
Handsome Devil
20992
0
Oct 26, 2012 20:34:21 GMT -8
ⓦ৹₪deⓡ
No animals were harmed in the feeding of this human.
925
March 2004
chickenturkeybacon
|
Post by ⓦ৹₪deⓡ on May 17, 2007 20:08:46 GMT -8
If you guys are having problems with the code, please provide a link to your forum and enable guest viewing so I can take a look at it. Chances are it's conflicting with another code. Oh, and check the database, I've updated the code so you can add a number to a dice roll. Previous versions did not work with modifiers. ~Wonder
|
|
inherit
91961
0
Jul 28, 2008 8:33:14 GMT -8
londonjohn
44
November 2006
londonjohn
|
Post by londonjohn on May 18, 2007 1:17:15 GMT -8
Hi ⓦ৹₪deⓡ, Thanks for the reply and letting us know of the updated code. On updating the code everything now seems to be working fine. In terms of opening the forum, the senior admin chappie (I am merely a minion) is not a big fan of changing the access, even temporarily. Sorry.
One question though, the new code removes the pop-up dialogue boxes asking for number of dice and number of sides on the dice. Was this a conscious decision to remove those features? I'm very happy with it either way, but I'll have to update the FAQ I've done. This isn't a moan, it really is curiosity as to the rationale behind your coding decisions. John (and p.s. huge thanks again for the code and the updating)
|
|
inherit
Handsome Devil
20992
0
Oct 26, 2012 20:34:21 GMT -8
ⓦ৹₪deⓡ
No animals were harmed in the feeding of this human.
925
March 2004
chickenturkeybacon
|
Post by ⓦ৹₪deⓡ on May 18, 2007 1:45:09 GMT -8
The code in the database never had the popup. I made that modification just for you. Here, this should do the same thing. Edit where indicated:<style type="text/css"> .dicebg {background-color: FFFFFF;border:solid 2px #000000;} .dicefont {background-color: FFFFFF;color: 000000; font-weight:bold;} </style> <script> //Dice Rolls In Posts v1.1
//Copyright 4-23-2007 ~Wonder //May be reposted anywhere as long as this header remains in tact
//Do you want the dice to line of horizontally(true) or vertically(false) diceAlignment=true;
//Enter URL of the image you want to appear as the dice ubbc button UBBCdiceImage="http://img100.imageshack.us/img100/6118/diceicon9rx.gif";
//Enter the default # of dice defaultDice=1;
//Enter the default # of sides defaultSides=6;
//Enable dice in preview? true or false enablePreview=true;
rs="";mainForm=""; if(document.postForm) { mainForm=document.postForm; if(location.href.match(/action\=modifypost/)){enablePreview=true;} mainForm.color.parentNode.innerHTML+="<a href=javascript:addMult()><img src=\""+UBBCdiceImage+"\" alt=\"Insert Dice Roll\" border=\"0\"></a>"; mainForm.onsubmit=addRand; mainForm.message.value=mainForm.message.value.replace(/(\[rand\=\d+\])/ig,""); rs=RegExp.$1; if(location.href.match(/quote\=\d+/)) { mainForm.message.value=mainForm.message.value.replace(/(\[dice\=\d+\])/ig,""); rs=""; } } else if(location.href.match(/action\=display/)) { ta=document.getElementsByTagName("textarea"); if(ta.length>0 && ta[0].name=="message") { mainForm=ta[0].parentNode; mainForm.onsubmit=addRand; } }
/////////////////////// if(location.href.match(/action\=(display|pmview|recent|userrecentposts|gotopost|search|calendarview)/) || (!location.href.match(/action\=/) && document.postForm && enablePreview)) { hr=document.getElementsByTagName("hr"); for(i=0;i<hr.length;i++) { if(typeof(hr[i].parentNode)!="undefined" && hr[i].parentNode.tagName=="TD" && typeof(hr[i].parentNode.lastChild)!="undefined" && typeof(hr[i].parentNode.lastChild.lastChild)!="undefined" && hr[i].parentNode.lastChild.lastChild.nodeType!=1) { n=hr[i].parentNode.lastChild; rand=n.innerHTML.match(/\[rand\=\d+\]/); if(rand!=null) { n.innerHTML=n.innerHTML.replace(rand[0],""); rand=rand[0].replace(/[^\d]/g,""); dice=n.innerHTML.match(/\[dice\=\d+(\+\d+)?\]/ig); if(dice!=null) { for(k=0;k<dice.length;k++) { numb=dice[k].match(/\d+(\+\d+)?/); numb=numb[0].split("+"); addon=numb.length>1?parseInt(numb[1],10):0; numb=parseInt(numb[0],10); roll=Math.round((parseFloat(rand.substring(k,k+2)+"."+rand.substring(k+2,rand.length))/100)*(numb-1))+1+addon; n.innerHTML=n.innerHTML.replace(dice[k],"<table "+(diceAlignment?"style=\"display:inline\"":"")+" border=0 cellpadding=0 cellspacing=0><tr><td><table class=dicebg cellpadding=1 cellspacing=0><tr><td><center><font class=dicefont size=\"+1\"><b>"+roll+"</b><br><font size=\"1\">"+numb+" sides"+(addon>0?"+"+addon:"")+"</font></font></center></td></tr></table></td></tr></table> "); } } } } } }
function addMult() { numb=prompt("How many dice?",defaultDice); sides=prompt("How many sides per die?",defaultSides); for(i=0;i<numb;i++) add("[dice="+sides+"]",""); } function addRand() { mainForm.message.value=mainForm.message.value.replace(/(\[rand\=\d+\])/ig,""); if((rs.length==0 && mainForm.message.value.match(/(\[dice\=\d+\])/)) && (enablePreview==true || (enablePreview==false && mainForm.nextaction.value=="post"))) { mainForm.message.value+="[rand="+(Math.random()+"").replace(/0\./,"")+(Math.random()+"").replace(/0\./,"")+(Math.random()+"").replace(/0\./,"")+( Math.random()+"").replace(/0\./,"")+"]"; } else { mainForm.message.value+=rs; } disable(mainForm); } </script>
|
|
inherit
46733
0
Dec 19, 2009 9:05:41 GMT -8
Magic Carrot
All Rights Reserved
861
June 2005
magiccarrot
|
Post by Magic Carrot on May 18, 2007 3:50:22 GMT -8
|
|
inherit
91961
0
Jul 28, 2008 8:33:14 GMT -8
londonjohn
44
November 2006
londonjohn
|
Post by londonjohn on May 18, 2007 6:27:45 GMT -8
Hi MC, I found that if you enter the modifier in the dialogue boxes then the modifier doesn't seem to work. Strangely, when you press 'Modify Post' and enter the modifier manually it does work. Also, if you use the dialogue boxes to enter the modifier for any dice roller over 1dx, the modifier will be added to every die roll. Therefore to get... 1d6+1 you need [dice=6+1] 2d6+1 you need [dice=6][dice=6+1] etc... John
|
|
inherit
46733
0
Dec 19, 2009 9:05:41 GMT -8
Magic Carrot
All Rights Reserved
861
June 2005
magiccarrot
|
Post by Magic Carrot on May 18, 2007 8:34:20 GMT -8
Hmmm.. well it *is* working, just not like it's supposed to. This code is good if someone needs to roll an attack for a Titanium Frost Bastard Sword + 5. ~ MC
|
|