Модуль:RandomMembers: відмінності між версіями

нема опису редагування
Немає опису редагування
Немає опису редагування
 
(Не показано 5 проміжних версій цього користувача)
Рядок 1: Рядок 1:
local p = {}
-- This module will handle the shuffling and display of random players.


function p.showRandomMembers(frame)
local p = {}  -- Define a table to hold your module's functions
     local category = 'Учасники_спільноти_MCC' -- Your category
 
     local count = -- How many members to display
function p.showRandomPlayers(frame)
     local pages = mw.site:getCategoryMembers(category, 'all', count)
     math.randomseed(os.time()) -- Seed the random number generator
 
    -- List of players
     local players = {
        "Індиго", "Адамант", "Алоха", "Аріель", "Берлін", "Бетмен", "Браун", "ВВ",
        "Дантес", "Демон", "Джордж", "Доктор Хаус", "Доктор Ямато", "Емесай", "ЕХС", "Кексік",
        "Керміт", "Клайд", "Клей", "Комар", "Лемур", "Містер Тен", "Малена", "Мальвінка",
        "Маска", "Мері", "Механік", "Ніколетта", "Оттерія", "Расм", "Сімон", "Справа",
        "Тайєр", "Тян", "Фавер", "Фаза", "Фейт", "Хантер", "Хоррорчік", "Шостік"
    }
   
    -- Shuffle players
     for i = #players, 2, -1 do
        local j = math.random(i)
        players[i], players[j] = players[j], players[i]
    end
 
    -- Collect the first four players
     local output = {}
     local output = {}
   
     for i = 1, 4 do
     for i, page in ipairs(pages) do
         table.insert(output, string.format('<p>[[%s|%s]]</p>', players[i], players[i]))
         table.insert(output, string.format('<p>[[%s|%s]]</p>', page.fullText, page.fullText))
        if i >= count then break end
     end
     end


Рядок 15: Рядок 30:
end
end


return p
return p -- Return the table to make its functions accessible to other modules