Anyway, I had three fields that would contain the value of another field * 5. So, "Idea" is INT * 5, "Luck" is POW * 5 and "Know" is EDU * 5. For example, in "Idea" the Source has, "txtINT.value * 5" (no quotes, of course).
These all worked just fine until I tried to enter a function for Damage Bonus. A character's Damage Bonus is based upon the addition of its STR and SIZ. The sum is looked up on a chart and a modifier is determined. For lower sums, I used an if/then process and for higher ones, I needed to divide the total by 16 and then add additional d6 according to the answer. At the end, I'll provide the code I wrote.
So, I wrote the code, put it in the Script tab and it failed. OK, fine, except that, for some reason, the other calculations - Idea, Luck and Know - stopped working. I remove the code, those calculations work again. So, not only is my code not working, it also causes everything else to fail.
If someone could take a gander at my code and let me know what I may have done wrong, I'd appreciate it.
Here's what I wrote;
- Code: Select all
function fDamageBonus()
{
int iSTRnSIZ = 0;
int iDamDice = 0;
if (iSTRnSIZ <= 12) {
return txtDamageBonus.text = '-1d6';
} else if (iSTRnSIZ <= 16) {
return txtDamageBonus.text = '-1d4';
} else if (iSTRnSIZ <= 24) {
return txtDamageBonus.text = '0';
} else if (iSTRnSIZ <= 32) {
return txtDamageBonus.text = '+1d4';
} else if (iSTRnSIZ <= 40) {
return txtDamageBonus.text = '+1d6';
} else if (iSTRnSIZ <= 56) {
return txtDamageBonus.text = '+2d6';
} else if (iSTRnSIZ <= 72) {
return txtDamageBonus.text = '+3d6';
} else if (iSTRnSIZ <= 88) {
return txtDamageBonus.text = '+4d6';
} else if (iSTRnSIZ > 88) {
iDamDice = int ((iSTRnSIZ - 88) / 16) + 5;
return txtDamageBonus.text = '+' + iDamDice + 'd6';
}
}
It fails no matter if I put fDamageBonus() as the Source of the Damage Bonus field or not. As long as this code exists in Script tab, nothing works.
A thought hit me and I removed the "txtDamageBonus.text = " from each return command (adding parentheses around "'+' + iDamDice + 'd6'", but no difference.
Any ideas?







