EarthDawn Die Rolling Function

Thoughts, Help, Feature Requests

Moderators: dorpond, Azhrei, giliath

Post Reply
SinniusGreen
Kobold
Posts: 3
Joined: Tue Oct 27, 2009 3:04 pm

EarthDawn Die Rolling Function

Post by SinniusGreen »

On my tabs, I've got a button for each step.
For example:
Step 1 is 1d4-2, and it's called by entering ED(4)-2
Step 10 is ED(10):ED(6)
Step 20, ED(20):ED(8):ED(6)
The function will re-roll max die rolls and add them together. Natural 1's will show up in red, and rolls that hit multiples show up in green.

If anyone can explain how to import saved tab(xml) files, that'd be great.

Here's my functions.js:

function registerFunctions() {
var map = new java.util.HashMap();
map.put("ED", step01);
return map;
}



function step01(a) {
row.label="ED("+a+")";
var roll = Math.floor(Math.random()*a)+1;
var result = roll;
if (roll == 1) {
row.setForegroundColor(255,0,0);
}
while (roll == a) {
roll = Math.floor(Math.random()*a)+1;
result = result + roll;
row.setForegroundColor(0, 255, 0);
row.label="ED("+a+")+";
}
return result;
}

Post Reply

Return to “DiceTool”