Module:User:NickTheRed37/RandomFact

-- Random facts module -- Created by Naista2002 on September 24-25, 2014 -- For use with the template User:Naista2002/Template/RandomFact.

local p = {}

-- I need this just to seed the RNG function leapDay(year) if (year % 400 == 0) or (year % 100 ~= 0 and year % 4 == 0) then return 1 else return 0 end end

local tb = os.date("*t") math.randomseed(tb.sec + tb.min*60 + tb.hour*3600 + tb.yday*86400 + tb.year*86400*(365+leapDay(tb.year)))

function p.randfact(f) -- Arguments local args = f:getParent.args -- Quotes local quotes = {} -- Initial text local starttext = "" -- Unused value local dm = nil for i, v in ipairs(args) do       if i == 1 then starttext = v           if starttext:sub(-1) == "\n" then starttext = starttext:sub(1, starttext:len-1) end else table.insert(quotes, v)       end end return "" .. starttext .. "... ..." .. quotes[math.random(#quotes)] .. " " end

return p