3415
редагувань
| Admin (обговорення | внесок) Немає опису редагування | Admin (обговорення | внесок)  Немає опису редагування | ||
| Рядок 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) | ||
|      math.randomseed(os.time())  -- Seed the random number generator | |||
|      math.randomseed(os.time()) | |||
|      -- List of players  |      -- List of players | ||
|      local players = { |      local players = { | ||
|          "Індиго", "Адамант", "Алоха", "Аріель", "Берлін", "Бетмен", "Браун", "ВВ", |          "Індиго", "Адамант", "Алоха", "Аріель", "Берлін", "Бетмен", "Браун", "ВВ", | ||
| Рядок 12: | Рядок 15: | ||
|      } |      } | ||
|      --  |      -- 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 | ||
|      --  |      -- Collect the first four players | ||
|      local output = {} |      local output = {} | ||
|      for i = 1,  |      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 | |||