This module is made to be used in {{User:NickTheRed37/Templates/RandomFact}}
.
[view | edit | history | purge]The above documentation is transcluded from Module:User:NickTheRed37/RandomFact/doc.
-- Random facts module
local p = {}
function p.randfact(f)
-- Arguments
local args = f:getParent().args
-- Quotes
local quotes = {}
-- Initial text
local starttext = ""
-- Seed the random number generator
math.randomseed(os.time())
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
-- Random selector
local id = math.random(#quotes)
return starttext .. "...<br />..." .. quotes[id]
end
return p