functions =
function functions.nyearsago(frame) current_year = tonumber(os.date("%Y")) given_year = tonumber(frame.args[1]) connector = false capitalize = false if frame.args[2]
"true" then capitalize = true end return "
" .. spelledout(current_year - given_year, connector, capitalize) .. " years ago"endfunction functions.rand(frame) math.randomseed(os.time) num = math.random(1, tonumber(frame.args[1])) return numend
function basicdigits(input_number)
digits = teens = tens = function oneto99(inp) if inp
0 then return tens[inp / 10 + 1] elseif inp > 9 and inp < 20 then return teens[inp - 9] elseif inp > 19 and inp < 100 then hyphen = "-" if inp % 10
function spelledout(given_number, connect, capitalize) connector = " " full_string = "" if tonumber(given_number)
true then connector = " and " end suffixes = j = 1 for i=string.len(given_number), 1, -3 do strend = i - 2 if strend < 1 then strend = 1 end spacing = "" if full_string ~= "" then spacing = " " end full_string = basicdigits(tonumber(string.sub(given_number, strend, i))) .. " " .. suffixes[j] .. spacing .. full_string j = j + 1 end if capitalize
function functions.spelledout(frame) return spelledout(frame.args[1])end
function functions.loopnum(frame) str = "" for i=1, tonumber(frame.args[1]) do str = str .. "\n\n" .. spelledout(i) end return strend
return functions