Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×

[Help] Creating Charater Sheet and roll Stats immediately

1382894673

Edited 1382894779
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!
I solved this myself by just extracting the code from the loop to a new funtion and passing the iterator to it. That did it.