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

нема опису редагування
Немає опису редагування
Немає опису редагування
 
Рядок 1: Рядок 1:
-- This module will handle the shuffling and display of random players.
local p = {}  -- Define a table to hold your module's functions
function p.showRandomPlayers(frame)
function p.showRandomPlayers(frame)
    -- Initialize random seed
     math.randomseed(os.time()) -- Seed the random number generator
     math.randomseed(os.time())


     -- List of players provided
     -- List of players
     local players = {
     local players = {
         "Індиго", "Адамант", "Алоха", "Аріель", "Берлін", "Бетмен", "Браун", "ВВ",
         "Індиго", "Адамант", "Алоха", "Аріель", "Берлін", "Бетмен", "Браун", "ВВ",
Рядок 12: Рядок 15:
     }
     }
      
      
     -- Shuffling the list to randomize
     -- Shuffle players
     for i = #players, 2, -1 do
     for i = #players, 2, -1 do
         local j = math.random(i)
         local j = math.random(i)
Рядок 18: Рядок 21:
     end
     end


     -- Selecting the first four players after shuffling
     -- Collect the first four players
     local output = {}
     local output = {}
     for i = 1, math.min(4, #players) do
     for i = 1, 4 do
         table.insert(output, string.format('<p>[[%s|%s]]</p>', players[i], players[i]))
         table.insert(output, string.format('<p>[[%s|%s]]</p>', players[i], players[i]))
     end
     end
Рядок 26: Рядок 29:
     return table.concat(output, "\n")
     return table.concat(output, "\n")
end
end
return p  -- Return the table to make its functions accessible to other modules