Content added Content deleted
(Created page with "-- [ Written by Tarkus Lee from the Dustloop wiki ] -- local p = {} function p.drawTierList(frame) local wikitext = "<div class=\"tierList\">" -- initialize the wikitext with the container for the list local character = "default" local numberOfTiers = tablelength(frame.args) local colors = {'b8ff89', 'fdff89', 'ffdf7f', 'ffbf7f', 'e98d87', 'ff7ff0', 'd17fff', '7fbfff', '7feeff', '7fffc3' } -- an array of pre-defined colors for index=1,numberOfTiers d...") |
mNo edit summary |
||
Line 7: | Line 7: | ||
local character = "default" |
local character = "default" |
||
local numberOfTiers = tablelength(frame.args) |
local numberOfTiers = tablelength(frame.args) |
||
local colors = {'b8ff89', 'fdff89', 'ffdf7f', 'ffbf7f', 'e98d87', 'ff7ff0', 'd17fff', '7fbfff', '7feeff', '7fffc3' } -- an array of pre-defined colors |
local colors = {'b8ff89', 'fdff89', 'ffdf7f', 'ffbf7f', 'e98d87', 'ff7ff0', 'd17fff', '7fbfff', '7feeff', '7fffc3', '15a876' } -- an array of pre-defined colors |
||
for index=1,numberOfTiers do |
for index=1,numberOfTiers do |
||
Line 18: | Line 18: | ||
wikitext = wikitext .. "<div class=\"tierHeader\" style=\"background-color: #" .. colors[1] .. "; border-top-left-radius: 4px;\">" .. tierLabel .. "</div>" |
wikitext = wikitext .. "<div class=\"tierHeader\" style=\"background-color: #" .. colors[1] .. "; border-top-left-radius: 4px;\">" .. tierLabel .. "</div>" |
||
elseif index == numberOfTiers then -- middle tiers are normal |
elseif index == numberOfTiers then -- middle tiers are normal |
||
wikitext = wikitext .. "<div class=\"tierHeader\" style=\"background-color: #" .. colors[index |
wikitext = wikitext .. "<div class=\"tierHeader\" style=\"background-color: #" .. colors[index] .. "; border-bottom-left-radius: 4px;\">" .. tierLabel .. "</div>" |
||
else -- final tier has a roudned bottom corner |
else -- final tier has a roudned bottom corner |
||
wikitext = wikitext .. "<div class=\"tierHeader\" style=\"background-color: #" .. colors[index |
wikitext = wikitext .. "<div class=\"tierHeader\" style=\"background-color: #" .. colors[index] .. ";\">" .. tierLabel .. "</div>" |
||
end |
end |
||
Revision as of 03:21, 17 August 2022
Tier List Generator written by Tarkus Lee from Dustloop
Module:Tier_List
is used to generate tier lists directly within the wiki using HTML, and the existing character labels.
Usage
A tier list requires that arguments be present in order.
- All of the tiers, ordered from top to bottom
Within a given tier, you must define the label for that tier (the letter that appears inside of the colored square) followed by a semicolon character (';').
Short Names in Labels
The tier list will attempt to find the appropriate icon and link for a given character. If you choose not to use the full name of a character, you must set up a necessary redirect from the short name to the full name. This applies to both the icon file and the character page itself.
Exampel
{{#invoke:Tier List|drawTierList |Top 10;Pikachu,Joker,Pyra,Roy,Peach,Pac-Man,Mii Brawler,Palutena,Fox,Steve |Top;Wolf,Mr. Game & Watch,R.O.B.,Mario,Sonic,Snake,Wario,Shulk,Pokemon Trainer,Samus,Sora,Zero Suit Samus,Young Link,Olimar,Lucina,Sheik,Cloud |High;Yoshi,Min Min,Captain Falcon,Terry,Ness,Ryu,Diddy Kong,Kazuya,Greninja,Byleth,Link,Chrom,Mega Man,Corrin,Luigi,Inkling,Hero,Sephiroth,Falco,Ken,Bowser,Incineroar |Mid;Lucas,Mewtwo,Wii Fit Trainer,Jigglypuff,Pichu,Duck Hunt,Bayonetta,Toon Link,Mii Gunner,Pit,Rosalina & Luma,Ike,Robin,Ridley,Villager,Richter,King K. Rool |Low;Zelda,Marth,Bowser Jr.,Isabelle,Kirby,Ice Climbers,Mii Swordfighter,Donkey Kong,Meta Knight,King Dedede,Banjo & Kazooie |Bottom;Lucario,Dr. Mario,Piranha Plant,Little Mac,Ganondorf }}
Lua error at line 18: attempt to concatenate local 'tierLabel' (a nil value).
-- [ Written by Tarkus Lee from the Dustloop wiki ] --
local p = {}
function p.drawTierList(frame)
local wikitext = "<div class=\"tierList\">" -- initialize the wikitext with the container for the list
local character = "default"
local numberOfTiers = tablelength(frame.args)
local colors = {'b8ff89', 'fdff89', 'ffdf7f', 'ffbf7f', 'e98d87', 'ff7ff0', 'd17fff', '7fbfff', '7feeff', '7fffc3', '15a876' } -- an array of pre-defined colors
for index=1,numberOfTiers do
local currentTier = trim(frame.args[index]) -- use the argument at the current index as current tier data
local tierLabel = string.match(currentTier, '(.*);') -- capture tier label from all characters before first ';'
currentTier = string.match(currentTier, ";(.*)") -- remove the tier label from the current tier data
--Inject tier label
if index == 1 then -- first tier should have a rounded top corner
wikitext = wikitext .. "<div class=\"tierHeader\" style=\"background-color: #" .. colors[1] .. "; border-top-left-radius: 4px;\">" .. tierLabel .. "</div>"
elseif index == numberOfTiers then -- middle tiers are normal
wikitext = wikitext .. "<div class=\"tierHeader\" style=\"background-color: #" .. colors[index] .. "; border-bottom-left-radius: 4px;\">" .. tierLabel .. "</div>"
else -- final tier has a roudned bottom corner
wikitext = wikitext .. "<div class=\"tierHeader\" style=\"background-color: #" .. colors[index] .. ";\">" .. tierLabel .. "</div>"
end
-- open a new tier container
if index ~= numberOfTiers then
wikitext = wikitext .. "<div class=\"tierGroup tierUnderline\">"
else -- final tier does not have an underline
wikitext = wikitext .. "<div class=\"tierGroup\">"
end
-- iterate over tokens in current tier, sperrated by ',' character
for token in string.gmatch(currentTier, '([^,]+)') do
character = token
-- inject StockIcon
local characterLabel = frame:expandTemplate{ title = 'StockIcon', args = { character } }
wikitext = wikitext .. "<div>" .. characterLabel .. "</div>"
end
-- close the current tier container
wikitext = wikitext .. "</div>"
end
-- close the entire tier list
wikitext = wikitext .. "</div>"
return wikitext
end
-- Return the size of a table by iterating over it and counting
function tablelength(T)
local count = 0
for _ in pairs(T) do count = count + 1 end
return count
end
function trim(s)
return (string.gsub(s, "^%s*(.-)%s*$", "%1"))
end
return p