Module:Cosmetic items: Difference between revisions
Jump to navigation
Jump to search
Pymonkibot (talk | contribs) m Text replacement - "[[Bloons Card Storm v" to "[[Update history:Bloons Card Storm/Version " |
Pymonkibot (talk | contribs) m Text replacement - "[[Bloons TD Battles 2 v" to "[[Update history:Bloons TD Battles 2/Version " |
||
| (One intermediate revision by the same user not shown) | |||
| Line 59: | Line 59: | ||
!class='unsortable'|Icon!!Text!!Unlock method(s)!!Introduced!!class='unsortable'|Notes]], | !class='unsortable'|Icon!!Text!!Unlock method(s)!!Introduced!!class='unsortable'|Notes]], | ||
{}, | {}, | ||
"[[Bloons TD 6 | "[[Update history:Bloons TD 6/Version %s|Version %s]]", | ||
"''To be added''" | "''To be added''" | ||
) | ) | ||
| Line 72: | Line 72: | ||
!class='unsortable'|Icon!!Text!!Unlock method(s)!!Introduced!!class='unsortable'|Notes]], | !class='unsortable'|Icon!!Text!!Unlock method(s)!!Introduced!!class='unsortable'|Notes]], | ||
{}, | {}, | ||
"[[Bloons TD 6 | "[[Update history:Bloons TD 6/Version %s|Version %s]]", | ||
"''To be added''" | "''To be added''" | ||
) | ) | ||
| Line 85: | Line 85: | ||
!class='unsortable'|Icon!!Text!!Unlock method(s)!!Introduced!!class='unsortable'|Notes]], | !class='unsortable'|Icon!!Text!!Unlock method(s)!!Introduced!!class='unsortable'|Notes]], | ||
{}, | {}, | ||
"[[Bloons TD Battles 2 | "[[Update history:Bloons TD Battles 2/Version %s|Version %s]]", | ||
"Launch" | "Launch" | ||
) | ) | ||
| Line 98: | Line 98: | ||
!class='unsortable'|Icon!!Text!!Tower!!Unlock method(s)!!Introduced!!class='unsortable'|Notes]], | !class='unsortable'|Icon!!Text!!Tower!!Unlock method(s)!!Introduced!!class='unsortable'|Notes]], | ||
{"tower %i"}, | {"tower %i"}, | ||
"[[Bloons TD Battles 2 | "[[Update history:Bloons TD Battles 2/Version %s|Version %s]]", | ||
"Launch" | "Launch" | ||
) | ) | ||
Latest revision as of 01:01, 24 April 2026
Module for displaying formatted tables of cosmetic items.
local p = {}
local parse = function(args, sourcesTable, tableHeader, tableExtras, versionText, versionDefault)
local sFormat = string.format
local tConcat = table.concat
local ret = {tableHeader}
-- get item sources
local sources = mw.ext.cargo.query(sourcesTable, "CONCAT('<ul>', GROUP_CONCAT('<li>', name, '</li>' ORDER BY name DESC SEPARATOR ''), '</ul>') = name, item", {
limit = 300,
where = sFormat("(item = '%s' OR item = '%s' OR item = '%s' OR item = '%s' OR item = '%s' OR item = '%s' OR item = '%s' OR item = '%s' OR item = '%s' OR item = '%s' OR item = '%s' OR item = '%s' OR item = '%s' OR item = '%s' OR item = '%s' OR item = '%s' OR item = '%s' OR item = '%s' OR item = '%s' OR item = '%s' OR item = '%s' OR item = '%s' OR item = '%s' OR item = '%s' OR item = '%s' OR item = '%s' OR item = '%s' OR item = '%s' OR item = '%s' OR item = '%s' OR item = '%s' OR item = '%s' OR item = '%s' OR item = '%s' OR item = '%s' OR item = '%s' OR item = '%s' OR item = '%s' OR item = '%s' OR item = '%s' OR item = '%s' OR item = '%s' OR item = '%s' OR item = '%s' OR item = '%s' OR item = '%s' OR item = '%s' OR item = '%s' OR item = '%s' OR item = '%s' OR item = '%s' OR item = '%s' OR item = '%s' OR item = '%s' OR item = '%s' OR item = '%s' OR item = '%s' OR item = '%s' OR item = '%s' OR item = '%s' OR item = '%s' OR item = '%s' OR item = '%s' OR item = '%s' OR item = '%s' OR item = '%s' OR item = '%s' OR item = '%s' OR item = '%s' OR item = '%s' OR item = '%s' OR item = '%s' OR item = '%s' OR item = '%s' OR item = '%s' OR item = '%s' OR item = '%s' OR item = '%s' OR item = '%s' OR item = '%s' OR item = '%s' OR item = '%s' OR item = '%s' OR item = '%s' OR item = '%s' OR item = '%s' OR item = '%s' OR item = '%s' OR item = '%s' OR item = '%s' OR item = '%s' OR item = '%s' OR item = '%s' OR item = '%s' OR item = '%s' OR item = '%s' OR item = '%s' OR item = '%s' OR item = '%s' OR item = '%s' OR item = '%s' OR item = '%s' OR item = '%s' OR item = '%s' OR item = '%s' OR item = '%s' OR item = '%s' OR item = '%s' OR item = '%s' OR item = '%s' OR item = '%s' OR item = '%s' OR item = '%s' OR item = '%s' OR item = '%s' OR item = '%s' OR item = '%s' OR item = '%s' OR item = '%s' OR item = '%s')", args["id 1"], args["id 2"], args["id 3"], args["id 4"], args["id 5"], args["id 6"], args["id 7"], args["id 8"], args["id 9"], args["id 10"], args["id 11"], args["id 12"], args["id 13"], args["id 14"], args["id 15"], args["id 16"], args["id 17"], args["id 18"], args["id 19"], args["id 20"], args["id 21"], args["id 22"], args["id 23"], args["id 24"], args["id 25"], args["id 26"], args["id 27"], args["id 28"], args["id 29"], args["id 30"], args["id 31"], args["id 32"], args["id 33"], args["id 34"], args["id 35"], args["id 36"], args["id 37"], args["id 38"], args["id 39"], args["id 40"], args["id 41"], args["id 42"], args["id 43"], args["id 44"], args["id 45"], args["id 46"], args["id 47"], args["id 48"], args["id 49"], args["id 50"], args["id 51"], args["id 52"], args["id 53"], args["id 54"], args["id 55"], args["id 56"], args["id 57"], args["id 58"], args["id 59"], args["id 60"], args["id 61"], args["id 62"], args["id 63"], args["id 64"], args["id 65"], args["id 66"], args["id 67"], args["id 68"], args["id 69"], args["id 70"], args["id 71"], args["id 72"], args["id 73"], args["id 74"], args["id 75"], args["id 76"], args["id 77"], args["id 78"], args["id 79"], args["id 80"], args["id 81"], args["id 82"], args["id 83"], args["id 84"], args["id 85"], args["id 86"], args["id 87"], args["id 88"], args["id 89"], args["id 90"], args["id 91"], args["id 92"], args["id 93"], args["id 94"], args["id 95"], args["id 96"], args["id 97"], args["id 98"], args["id 99"], args["id 100"], args["id 101"], args["id 102"], args["id 103"], args["id 104"], args["id 105"], args["id 106"], args["id 107"], args["id 108"], args["id 109"], args["id 110"], args["id 111"], args["id 112"], args["id 113"], args["id 114"], args["id 115"], args["id 116"], args["id 117"], args["id 118"], args["id 119"], args["id 120"]),
groupBy = "item"
})
-- create {id: source} pairs for each item
sourcesById = {}
for i = 1, #sources do
sourcesById[sources[i].item] = i
end
for i = 1, 120 do
local id = args[sFormat("id %i", i)]
if id == "" then break end
-- any extra table columns to insert between the standard ones
local extras = {}
for ii, str in ipairs(tableExtras) do
extras[ii] = args[sFormat(str, i)]
end
extras = tConcat(extras, "||") .. "||"
-- insert table row
ret[i+1] = sFormat(
[=[|style="text-align:center" id="%s"|[[File:%s|50x50px]]
|'''%s'''%s||%s%s||%s||%s]=],
args[sFormat("name %i", i)],
args[sFormat("image %i", i)],
args[sFormat("name %i", i)],
args[sFormat("description %i", i)] ~= "" and ("<br>" .. args[sFormat("description %i", i)]) or "",
extras == "||" and "" or extras,
sourcesById[id] ~= nil and sources[sourcesById[id]].name or "''To be added''",
args[sFormat("introduced %i", i)] ~= "" and sFormat(versionText, args[sFormat("introduced %i", i)], args[sFormat("introduced %i", i)]) or versionDefault,
args[sFormat("notes %i", i)]
)
end
ret[#ret+1] = "|}"
return tConcat(ret, "\n|-\n")
end
-- trophy store items
p["BTD6"] = function(frame)
return parse(
frame.args,
"btd6_cosmetic_sources",
[[{|class='wikitable sortable'
!class='unsortable'|Icon!!Text!!Unlock method(s)!!Introduced!!class='unsortable'|Notes]],
{},
"[[Update history:Bloons TD 6/Version %s|Version %s]]",
"''To be added''"
)
end
-- team flair items
p["BTD6 teams"] = function(frame)
return parse(
frame.args,
"btd6_team_cosmetic_sources",
[[{|class='wikitable sortable'
!class='unsortable'|Icon!!Text!!Unlock method(s)!!Introduced!!class='unsortable'|Notes]],
{},
"[[Update history:Bloons TD 6/Version %s|Version %s]]",
"''To be added''"
)
end
-- bling items
p["BTDB2 bling"] = function(frame)
return parse(
frame.args,
"btdb2_cosmetic_sources",
[[{|class='wikitable sortable'
!class='unsortable'|Icon!!Text!!Unlock method(s)!!Introduced!!class='unsortable'|Notes]],
{},
"[[Update history:Bloons TD Battles 2/Version %s|Version %s]]",
"Launch"
)
end
-- tower customization items
p["BTDB2 customization"] = function(frame)
return parse(
frame.args,
"btdb2_cosmetic_sources",
[[{|class='wikitable sortable'
!class='unsortable'|Icon!!Text!!Tower!!Unlock method(s)!!Introduced!!class='unsortable'|Notes]],
{"tower %i"},
"[[Update history:Bloons TD Battles 2/Version %s|Version %s]]",
"Launch"
)
end
-- general items
p["BCS"] = function(frame)
return parse(
frame.args,
"bcs_rewards",
[[{|class='wikitable sortable'
!class='unsortable'|Icon!!Text!!Unlock method(s)!!Introduced!!class='unsortable'|Notes]],
{},
"[[Update history:Bloons Card Storm/Version %s|Version %s]]",
"Launch"
)
end
-- hero items
p["BCS hero"] = function(frame)
return parse(
frame.args,
"bcs_rewards",
[[{|class='wikitable sortable'
!class='unsortable'|Icon!!Text!!Hero!!Unlock method(s)!!Introduced!!class='unsortable'|Notes]],
{"hero %i"},
"[[Update history:Bloons Card Storm/Version %s|Version %s]]",
"Launch"
)
end
return p