Модуль:Men4Gallery
Документацію для цього модуля можна створити у Модуль:Men4Gallery/документація
local all_men = mw.loadData('Модуль:Men4Gallery/Data')
local export = {}
function export.random( frame )
local men = all_men[frame.args[1]]
local qnt = frame.args[2]
if qnt == nil then
qnt = 6
end
local len = 0
repeat
len = len + 1
until men[len] == nil
len = len - 1
local result = {}, r
local str = '\n<gallery mode="packed-hover" heights="125px" widths="125px" class="gallery-withborders">\n'
local limit = math.min(len, qnt)
local i = 0, j, k
math.randomseed( os.time() )
while i < limit do
j = math.random(1, len)
r = #result
k = 1
while k <= r do
if result[k] == j then
break
end
k = k + 1
end
if k > r then
table.insert(result, j)
i = i + 1
end
end
for i =1, #result do
j = result[i]
str = str .. men[j][1] .. '|[[Автор:' .. men[j][2] .. '|{{smaller|' .. men[j][2] .. '}}]]' .. '\n'
end
str = str .. '</gallery>\n'
return frame:preprocess(str)
end
return export