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

нема опису редагування
(Створена сторінка: local p = {} function p.showRandomMembers(frame) local count = 4 -- Number of random members to display local category = 'Учасники_спільноти_MCC' -- The category to fetch from local members = mw.site:pagesInCategory(category, 'random', count) local output = {} for member in pairs(members) do table.insert(output, string.format('<p>%s</p>', member.fullText)) end return table.concat(output, "\n") e...)
 
Немає опису редагування
Рядок 4: Рядок 4:
     local count = 4  -- Number of random members to display
     local count = 4  -- Number of random members to display
     local category = 'Учасники_спільноти_MCC'  -- The category to fetch from
     local category = 'Учасники_спільноти_MCC'  -- The category to fetch from
     local members = mw.site:pagesInCategory(category, 'random', count)
     local pages = mw.site.pagesInCategory(category)
     local output = {}
     local output = {}
    local displayed = {}


     for member in pairs(members) do
    -- Fetching random pages
         table.insert(output, string.format('<p>[[%s]]</p>', member.fullText))
     for i = 1, math.min(count, #pages) do
        local index = math.random(#pages)
        while displayed[index] do
            index = math.random(#pages)
        end
        displayed[index] = true
        local title = pages[index].title
         table.insert(output, string.format('<p>[[%s|%s]]</p>', title, title))
     end
     end