v1.4.0.5
I have a function that's mostly working fine. What it does is you pass it the # of dice to roll.
It rolls the dice, and displays each die rolled (pulling an image from a table).
Code: Select all
<image src='[r: tblImage("White", s, 20) ]'> </image>
It get's tricky, however, since I have some additional conditions that pull the image from a couple different tables (ie different colored dice to represent different types of rolls).
So my function looks like this:
Code: Select all
[h: rNum = arg(0) ]
[h: abort(length(rNum))]
[h: mod = arg(1) ]
[h: rMode = arg(2) ]
[h: rKmod = arg(3) ]
[h: ts=0]
[h: tb=0]
[h: rHalf = if ( rNum == floor(rNum), 0, 1 ) ]
[h: rNum = floor ( rNum ) ]
[r: rNum][r,if(rHalf==1),CODE:{½};{}]d6[r: strformat ( "%+d", mod ) ] <br>
[r,switch(rMode),code:
case "knockback": {
[r,for(i,0,rNum,1,""), CODE: {
[h:s=1d6]
<image src='[r: tblImage("White", s, 20) ]'> </image>
[h:ts=ts+s]
}]
[h:ts=ts+mod]
[h: lBODY = rKmod]
[h: lROLL = ts ]
<br>
<b>Knockback:</b> [r: lBODY - lROLL ]
};
case "raw": {
[r,for(i,0,rNum,1,""), CODE: {
[h:s=1d6]
<image src='[r: tblImage("White", s, 20) ]'> </image>
[h:ts=ts+s]
}]
[h:ts=ts+mod]
<br>
<b>Total:</b> [r: ts]
};
case "normal": {
[r,for(i,0,rNum,1,""), CODE: {
[h:s=1d6]
<image src='[r: tblImage("White", s, 20) ]'> </image>
[h:b=if(s==6,2,if(s==1,0,1))]
[h:ts=ts+s]
[h:tb=tb+b]
}]
[h:ts=ts+mod]
<br>
<b>Stun:</b> [r: ts] ( <b>Body:</b> [r: tb] )
};
case "killing": {
[r,for(i,0,rNum,1,""), CODE: {
[h:b=1d6]
<image src='[r: tblImage("Red", b, 20) ]'> </image>
[h:tb=tb+b]
}]
[r, if ( rHalf > 0 ), CODE: {
[h:b=1d3]
<image src='[r: tblImage("Red", b, 15) ]'> </image>
[h:tb=tb+b]
};{}]
[h:tb=tb+mod]
[h:s=1d6]
<image src='[r: tblImage("Black", s, 20) ]'> </image>
[h:s=s-1+rKmod]
[h:ts=s*tb]
<br>
<b>Body:</b> [r: tb] ( <b>Stun:</b> [r: ts] )
}
]
With 1 small problem. If I put a large # of dice in (say 33), it dumps the 33 dice images all in 1 line, and won't wrap them. So depending on how the chat window is setup, you don't see all the rolls.
I tried playing with html tables, but couldn't get them to change the behaviour.
I tried putting a space in the loop:
Code: Select all
[r,for(i,0,rNum,1," "), CODE: {
^
space added here
I tried adding a conditional:
Code: Select all
[h, if ( condition ), CODE: { <br> };{}]
So a few questions:
1) Is there are shorter way of writing a coditional Line break (ie <br> ) that avoids using "CODE: { }" ??
2) Is there any way to use HTML tables to force it to wrap the line ?
3) Is there any other way to pull this off ?
4) Any feedback/suggestions on the code would be appreciated as well
Thanks!