Insanity
May 11th, 2007, 15:59
I've done some searching, but could not find the documentation of the math functions supported in the .xml scripting. In the d20 charsheet_templates.xml file, within the template for abilitybonus, there is a line that reads:
<script>
function onSourceUpdate()
setValue(math.floor((sources[scorefield[1]].getValue() - sources[damagefield[1]].getValue() - 10) / 2) + getModifier());
end
function onInit()
addSource(scorefield[1]);
addSource(damagefield[1]);
super.onInit();
end
</script>
This is where the bonuses for an ability are calculated. I've been able to change it to get different results. What I am looking for is how to say round to nearest integer and such. Or even If x>=20, y= type functions. Any ideas?
<script>
function onSourceUpdate()
setValue(math.floor((sources[scorefield[1]].getValue() - sources[damagefield[1]].getValue() - 10) / 2) + getModifier());
end
function onInit()
addSource(scorefield[1]);
addSource(damagefield[1]);
super.onInit();
end
</script>
This is where the bonuses for an ability are calculated. I've been able to change it to get different results. What I am looking for is how to say round to nearest integer and such. Or even If x>=20, y= type functions. Any ideas?