Module:Age

ElvenAge = {} ElvenAge.Age_Division = function(real_age,divisor) if real_age < 18 then return real_age else return ((real_age - 18) / divisor) + 18 end end ElvenAge.Age_Multiply = function(real_age) if real_age < 18 then return real_age else return (real_age - 18) * (8.5 * math.pow(1.0474757339,((real_age - 18) / 18))) + 18 end end

function format_age(formatt,birth,now) local formatt2 = formatt if string.sub(formatt2,-1) == "*" then formatt = string.sub(formatt,1,string.len(formatt)-1) end if string.sub(formatt,-5) == "_true" then formatt = string.sub(formatt,1,string.len(formatt)-5) now = math.floor(now * 365.25 / 376) birth = math.floor(birth * 365.25 / 376) else now = now birth = birth end local years = now - birth if formatt == "" then years = years elseif formatt == "true" then if string.sub(formatt2,-1) == "*" then now = math.floor(now * 365.25 / 376) birth = math.floor(birth * 365.25 / 376) years = now - birth else years = math.floor(years * 365.25 / 376) end elseif formatt == "elf" then years = ElvenAge.Age_Division(years,10) elseif formatt == "half_elf" then years = ElvenAge.Age_Division(years,5) elseif formatt == "orc" then years = ElvenAge.Age_Division(years,2.93548) elseif formatt == "half_orc" then years = ElvenAge.Age_Division(years,1.46774) elseif formatt == "lizardman" then years = ElvenAge.Age_Division(years,14.22581) elseif formatt == "halfling" then years = ElvenAge.Age_Division(years,2.12903) elseif formatt == "gnome" then years = ElvenAge.Age_Division(years,5.65278) elseif formatt == "limjiang" then years = ElvenAge.Age_Division(years,1.83838) elseif formatt == "azisiri" then years = ElvenAge.Age_Division(years,2.7647058823529) end if string.sub(formatt2,-1) == "*" then return math.floor(years) else return years end end

local p={} function p.main(frame) return format_age(frame.args[1],tonumber(frame.args[2]),tonumber(frame.args[3])) end return p