PDA

View Full Version : Math Functions in FGII?



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?

joshuha
May 11th, 2007, 16:35
LUA is the scripting language used. For the math lib look here for reference https://www.lua.org/manual/5.1/manual.html#5.6

Insanity
May 11th, 2007, 16:49
thanks for the source