Module:AliensRandom

local p = {}

local template =

local output = [=[

function p.main(frame) local listtext = frame.args.list local list = {} for line in listtext:gmatch('[^\n]+') do       list[#list + 1] = line:match('^%*?%s*(.-)%s*$') end math.randomseed(os.time) for n = 0, 7 do       local max = #list - n        local selection = math.random(1, max) if selection ~= max then list[selection], list[max] = list[max], list[selection] end end local result = {unpack(list, #list - 7)} for index, item in ipairs(result) do       local args = {} for arg in item:gmatch('[^%|]+') do           args[#args + 1] = arg end local file = args[1] local article = args[2] local display = args[3] or args[2] result[index] = template:format(article, display, file, display, article) end return output:format(unpack(result)) end

return p