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

нема опису редагування
(Створена сторінка: local p = {} function p.fetchCategoryData(frame) local categoryName = "Учасники_спільноти_MCC" -- The category to fetch from local continue = nil local pages = {} repeat local query = mw.smw.ask('Category:' .. categoryName .. '|limit=500' .. (continue and '|continue=' .. continue or '')) for _, page in pairs(query) do table.insert(pages, page.fullText) end continue = query["...)
 
Немає опису редагування
 
(Не показано 8 проміжних версій цього користувача)
Рядок 1: Рядок 1:
local p = {}
local p = {}


function p.fetchCategoryData(frame)
function p.showRandomPlayers(frame)
     local categoryName = "Учасники_спільноти_MCC"  -- The category to fetch from
     -- List of players provided
     local continue = nil
     local players = {
    local pages = {}
        "Індиго", "Адамант", "Алоха", "Аріель", "Берлін", "Бетмен", "Браун", "ВВ",
    repeat
         "Дантес", "Демон", "Джордж", "Доктор Хаус", "Доктор Ямато", "Емесай", "ЕХС", "Кексік",
         local query = mw.smw.ask('[[Category:' .. categoryName .. ']]|limit=500' .. (continue and '|continue=' .. continue or ''))
         "Керміт", "Клайд", "Клей", "Комар", "Лемур", "Містер Тен", "Малена", "Мальвінка",  
         for _, page in pairs(query) do
         "Маска", "Мері", "Механік", "Ніколетта", "Оттерія", "Расм", "Сімон", "Справа",
            table.insert(pages, page.fullText)
         "Тайєр", "Тян", "Фавер", "Фаза", "Фейт", "Хантер", "Хоррорчік", "Шостік"
         end
     }
         continue = query["query-continue-offset"]  -- If more than 500 results, need to continue querying
   
     until not continue
     -- Shuffling the list to randomize
 
     for i = #players, 2, -1 do
     -- Start the wikitable
        local j = math.random(i)
     local output = '{| class="wikitable sortable" style="text-align:center;"\n! Учасник\n! Page Link\n'
        players[i], players[j] = players[j], players[i]
    end


     -- Add rows to the wikitable
     -- Selecting the first four players after shuffling
     for _, pageTitle in ipairs(pages) do
    local output = {}
         output = output .. '|-\n| ' .. pageTitle .. '\n| [[' .. pageTitle .. ']]\n'
     for i = 1, math.min(4, #players) do
         table.insert(output, string.format('<p>[[%s|%s]]</p>', players[i], players[i]))
     end
     end


     -- Close the wikitable
     return table.concat(output, "\n")
    output = output .. '|}\n'
    return output
end
end


return p
return p