Hey, I am currently setting up a Character Sheet generator for Dark Heresy but I encountered a problem which I don't know how to solve. I set up the Characteristics with the modifiers dh.attr = [];
dh.attr.ws = { name: "WS", mod: [20, 20, 20, 20]};
dh.attr.bs = { name: "BS", mod: [20, 20, 20, 20]};
dh.attr.str = { name: "S", mod: [25, 20, 20, 15]};
dh.attr.t = { name: "T", mod: [25, 15, 20, 20]};
dh.attr.ag = { name: "Ag", mod: [20, 20, 20, 20]};
dh.attr.inte = { name: "Int", mod: [20, 20, 20, 20]};
dh.attr.per = { name: "Per", mod: [20, 20, 20, 20]};
dh.attr.wp = { name: "WP", mod: [15, 20, 20, 25]};
dh.attr.fel = { name: "Fel", mod: [15, 25, 20, 20]}; Now I am trying to create a Character and based on his Homeworld he gets different roll modifiers dh.rollCharacteristics = function rollCharacteristics(world, pc) {
/*Roll and write Characteristics for the PC*/
sendChat("CC", "<b>Rolling Characteristics - " + world + "</b>");
for (var i in dh.attr) {
sendChat("CC", "/r 2d10+" + dh.attr[i].mod[dh.homeWorld.indexOf(world)], function (rolls){
var result = JSON.parse(rolls[0].content).total;
sendChat("CC", dh.attr[i].name + ":<b> " + result + "</b>");
createObj("attribute", {
name: dh.attr[i].name,
current: result,
characterid: pc.id
});
});
}
return;
};
But probably due to the fact that I create a function within a loop it is behaving not as expected and only rolls with the last Characteristic (Name and Modifier). Does anybody know how to fix this? Thanks in advance!