### help with function

Posted:

**Sat Jan 03, 2009 6:27 pm**Could someone help me out with this?

I've edited the function file and included:

The function works, but my problems are two-fold:

1. the result of the roll is a floating point number (like when you roll using the cumulative setting) and not just an integer like when you roll multiple dice

2. if the last roll in the list is highlighted then the row separating rolls is also highlighted green

I assume that these 2 problems are caused by something in dicetool that I cannot modify in the functions file, but can anyone help me fix these 2 problems?

I've edited the function file and included:

Code: Select all

`function attack(hit) { `

var die = 20;

row.setLabel("d20");

var roll = Math.floor(Math.random() * die) + 1;

if (roll <= hit) row.setBackgroundColor(0, 255, 0);

return parseInt(roll);

}

The function works, but my problems are two-fold:

1. the result of the roll is a floating point number (like when you roll using the cumulative setting) and not just an integer like when you roll multiple dice

2. if the last roll in the list is highlighted then the row separating rolls is also highlighted green

I assume that these 2 problems are caused by something in dicetool that I cannot modify in the functions file, but can anyone help me fix these 2 problems?