Joritochip (talk | contribs) mNo edit summary Tag: Source edit |
Joritochip (talk | contribs) m (Temporary change for performance testing) |
||
(11 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
--- Functions for making lists of players |
--- Functions for making lists of players |
||
− | -- @require |
+ | -- @require Dev:Links |
-- @require Module:Player link |
-- @require Module:Player link |
||
-- @require Module:RobloxUrls |
-- @require Module:RobloxUrls |
||
-- @require Module:Utils |
-- @require Module:Utils |
||
-- <nowiki> |
-- <nowiki> |
||
− | local links = require(" |
+ | local links = require("Dev:Links") |
local player_link = require("Module:Player link") |
local player_link = require("Module:Player link") |
||
local roblox_urls = require("Module:RobloxUrls") |
local roblox_urls = require("Module:RobloxUrls") |
||
Line 16: | Line 16: | ||
-- @param {table} args A table with player names as values. |
-- @param {table} args A table with player names as values. |
||
-- @return {string} Wikitext for list of players. |
-- @return {string} Wikitext for list of players. |
||
− | function p._player_list(args) |
+ | function p._player_list(args, forceDPL) |
+ | forceDPL = true -- temporary |
||
args = utils.trim_positional_arguments(args) |
args = utils.trim_positional_arguments(args) |
||
local items = {} |
local items = {} |
||
− | if #args <= 90 then |
+ | if #args <= 90 and not forceDPL then |
for _, name in ipairs(args) do |
for _, name in ipairs(args) do |
||
local item = "* " .. player_link._player_link{player = name} |
local item = "* " .. player_link._player_link{player = name} |
||
Line 29: | Line 30: | ||
local page_set = utils.array_to_set(pages) |
local page_set = utils.array_to_set(pages) |
||
for _, name in ipairs(args) do |
for _, name in ipairs(args) do |
||
− | local title = mw. |
+ | local title = mw.title.makeTitle('Community', name) |
if title and page_set[title.prefixedText] then |
if title and page_set[title.prefixedText] then |
||
− | local item = "* " .. links. |
+ | local item = "* " .. links.link(title.fullText, name, "local") |
table.insert(items, item) |
table.insert(items, item) |
||
else |
else |
||
− | local item = "* " .. links. |
+ | local item = "* " .. links.link(tostring(roblox_urls.user_from_username(name)), name, "ext") |
table.insert(items, item) |
table.insert(items, item) |
||
end |
end |
Revision as of 02:57, 7 June 2021
Functions for making lists of players
Documentation
Package items
player_list._player_list(args)
(function)- Create an unordered list of players with links. This function makes an attempt to avoid exceeding the expensive function limit.
- Parameter:
args
A table with player names as values. (table) - Returns: Wikitext for list of players. (string)
--- Functions for making lists of players
-- @require Dev:Links
-- @require Module:Player link
-- @require Module:RobloxUrls
-- @require Module:Utils
-- <nowiki>
local links = require("Dev:Links")
local player_link = require("Module:Player link")
local roblox_urls = require("Module:RobloxUrls")
local utils = require("Module:Utils")
local p = {}
--- Create an unordered list of players with links.
-- This function makes an attempt to avoid exceeding the expensive function limit.
-- @param {table} args A table with player names as values.
-- @return {string} Wikitext for list of players.
function p._player_list(args, forceDPL)
forceDPL = true -- temporary
args = utils.trim_positional_arguments(args)
local items = {}
if #args <= 90 and not forceDPL then
for _, name in ipairs(args) do
local item = "* " .. player_link._player_link{player = name}
table.insert(items, item)
end
else
local pages = require('Module:Player pages')
local page_set = utils.array_to_set(pages)
for _, name in ipairs(args) do
local title = mw.title.makeTitle('Community', name)
if title and page_set[title.prefixedText] then
local item = "* " .. links.link(title.fullText, name, "local")
table.insert(items, item)
else
local item = "* " .. links.link(tostring(roblox_urls.user_from_username(name)), name, "ext")
table.insert(items, item)
end
end
end
return table.concat(items, "\n")
end
p.player_list = utils.make_wrapper_function(p._player_list)
return p