Post by ⓦ৹₪deⓡ on May 18, 2007 23:07:08 GMT -8
Ok, I've fixed the problem. The database has been updated.
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...
JohnHere, I think this will do what you ask. Edit where indicated:
londonjohn said:
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
<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 dice
defaultDice="6d6+1";
//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("Enter dice:",defaultDice).split("d");
if(numb.length>1 && numb[0]>0)
{
numb[1]=numb[1].split("+");
for(i=0;i<numb[0]-1;i++)
add("[dice="+numb[1][0]+"]","");
add("[dice="+numb[1][0]+(numb[1].length>1?"+"+numb[1][1]:"")+"]","");
}
else
addMult();
}
function addRand()
{
mainForm.message.value=mainForm.message.value.replace(/(\[rand\=\d+\])/ig,"");
if((rs.length==0 && mainForm.message.value.match(/(\[dice\=\d+(\+\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>