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 local birth2 = birth local now2 = now local final_rounding_flag = false if string.sub(formatt2,-1) == "*" then formatt2 = string.sub(formatt2,1,string.len(formatt2)-1) final_rounding_flag = true end if string.sub(formatt2,-5) == "_true" then formatt2 = string.sub(formatt2,1,string.len(formatt2)-5) now2 = math.floor(now * 365.25 / 376) birth2 = math.floor(birth * 365.25 / 376) elseif formatt2 == "true" then now2 = math.floor(now * 365.25 / 376) birth2 = math.floor(birth * 365.25 / 376) else now2 = math.floor(now) birth2 = math.floor(birth) end local years = now2 - birth2 if formatt2 == "elf" then years = ElvenAge.Age_Division(years,10) elseif formatt2 == "half_elf" then years = ElvenAge.Age_Division(years,5) elseif formatt2 == "orc" then years = ElvenAge.Age_Division(years,2.93548) elseif formatt2 == "half_orc" then years = ElvenAge.Age_Division(years,1.46774) elseif formatt2 == "lizardman" then years = ElvenAge.Age_Division(years,14.22581) elseif formatt2 == "halfling" then years = ElvenAge.Age_Division(years,2.12903) elseif formatt2 == "gnome" then years = ElvenAge.Age_Division(years,5.65278) elseif formatt2 == "limjiang" then years = ElvenAge.Age_Division(years,1.83838) elseif formatt2 == "azisiri" then years = ElvenAge.Age_Division(years,2.7647058823529) end if final_rounding_flag == true 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