Hi. 🙂
I'm currently trying to create a loop in a function but I'm struggerling quite badly on a how to get this code to work.
This is the dev code I currently have:
function modifier_calc($skill_level)
{
if($skill_level > '11')
{
// Must have at least 12 points in the skill/characteristic before positive modifier is applied
// Gains +1 modifier for every 2 levels, ie. 12-13 (+1), 14-15 (+2), 16-17 (+3), etc, etc
for($p = 12; $p < $skill_level; $p++)
{
$modifier = ;
}
}
else
{
// Less than 12 skill/characteristic points means no modifier to user
$modifier = '0';
}
return $modifier;
}
What I'm trying to do is if the variable ($skill_level) is at least '12' then I need it to go into the loop and work out how which modifier it is related too.
for($p = 12; $p < $skill_level; $p++)
{
$modifier = ;
}
For example:
$skill_level = 12 or 13 then $modifier = 1,
$skill_level = 14 or 15 then $modifier = 2,
$skill_level = 16 or 17 then $modifier = 3,
etc, etc.
I cannot for the life of me work out how to achieve this.
Any help would be greatly apprieciated. 🙂