Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.
Revision as of 17:13, 8 March 2026 by Muqsit (talk | contribs) (Created page with "local p = {} local html function p.drawTierList(frame) html = mw.html.create('div'):addClass('tierList')-- initialize the wikitext with the container for the list local GAME = frame.args[1]:gsub("%s+", "") -- capture the target game from the first arg local character = "default" local numberOfTiers = tablelength(frame.args) local colors = { '#b8ff89', '#fdff89', '#ffdf7f', '#ffbf7f','#e98d87', '#ff7ff0', '#d17fff', '#7fbfff', '#7feeff', '#7fffc3' }...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Module:Tier_List is used to generate tier lists directly within the wiki.

It currently supports three rendering methods:

  • drawSimple – renders entries directly from the provided text
  • drawIcons – renders entries from manually specified icon files
  • drawCargoTable – renders entries using Cargo data

Usage

drawSimple

Use drawSimple when you want to render a tier list directly from the provided text without using Cargo.

Required argument order:

  1. All tiers, ordered from top to bottom

Within each tier, define the tier label first, followed by a semicolon character (;), then a comma-separated list of item names.

Example

{{#invoke:Tier List|drawSimple
|S;Blackout,Divine Immolation,Godly Overload,Deadly Disarmor
|A;Bleed,Deathbringer,Guardians,Gears,Execute
|B;Angelic,Armored,Dodge,Enlighted,Ghost
|C;Auto Smelt,Haste,Glowing,Headless,Confusion
|D;Aquatic,Anti Gravity,Experience,Decapitation
}}

Script error: The function "drawSimple" does not exist.

drawIcons

Use drawIcons when you want to define each item directly with its own icon file, without using Cargo.

Required argument order:

  1. All tiers, ordered from top to bottom

Within each tier, define the tier label first, followed by a semicolon character (;), then a comma-separated list of items.

Each item must use this format:

  • Display Name::FileName.ext

Example

{{#invoke:Tier List|drawIcons
|S;Flint::Flint.png,Emerald::Emerald.png,Quartz::Quartz.png,Experience Bottle::Experience bottle.png
|A;Tripwire Hook::Tripwire hook.png,Milk Bucket::Milk bucket.png,Paper::Paper.png,Blaze Rod::Blaze rod.png
|B;Redstone Torch::Redstone torch.png,Glowstone Dust::Glowstone dust.png,Ender Pearl::Ender pearl.png,Spider Eye::Spider eye.png
|C;Green Dye::Green dye.png,Cyan Dye::Cyan dye.png,Light Gray Dye::Light gray dye.png,Orange Dye::Orange dye.png
|D;Red Dye::Red dye.png,Map::Map.png,Ink Sac::Ink sac.png,Firework Star::Firework star.png
}}

Script error: The function "drawIcons" does not exist.

drawCargoTable

Use drawCargoTable when the first argument is the name of a Cargo table, and the remaining arguments are the tiers in top-to-bottom order.

Required argument order:

  1. Cargo table name
  2. All tiers, ordered from top to bottom

Within each tier, define the tier label first, followed by a semicolon character (;), then a comma-separated list of item names.

The item names should match the values stored in the Cargo table exactly.

Example: Masks

{{#invoke:Tier List|drawCargoTable
|Mask
|S;Zeus,Monopoly,Thanos,Animal Control
|A;Anonymous,Anti-Silence,Bunny,Death Knight,Death Wish
|B;Equalizer,Ghost,Glitch,Grave Digger
|C;Headless,Holy,Joker,Lover,Monopoly,Muqsit
|D;Necromancer,Outpost,Party,Pilgrim
}}

Script error: The function "drawCargoTable" does not exist.

Notes

  • drawSimple does not query Cargo and only displays the provided labels directly.
  • drawIcons does not query Cargo and renders each item using the explicitly supplied icon file.
  • For drawIcons, each item must use the format Display Name::FileName.ext.
  • drawCargoTable expects the first argument to be a valid Cargo table name.
  • For Cargo rendering, item names must match the stored name values exactly.
  • drawTierList may still exist as an alias for drawCargoTable if backward compatibility is enabled.

local p = {}
local html

function p.drawTierList(frame)
  html = mw.html.create('div'):addClass('tierList')-- initialize the wikitext with the container for the list
  local GAME = frame.args[1]:gsub("%s+", "") -- capture the target game from the first arg
  local character = "default"
  local numberOfTiers = tablelength(frame.args)
  local colors = {
  	'#b8ff89', '#fdff89', '#ffdf7f',
  	'#ffbf7f','#e98d87', '#ff7ff0',
  	'#d17fff', '#7fbfff', '#7feeff', '#7fffc3'
  }

  for index=2,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 == 2 then -- first tier should have a rounded top corner
    	html:tag('div'):addClass('tierHeader'):css('background-color', colors[1])
    		:wikitext(tierLabel)
    	:done()
    else
		html:tag('div'):addClass('tierHeader'):css('background-color', colors[index-1])
    		:wikitext(tierLabel)
    	:done()
    end
    
    -- open a new tier container
    local tierGroup = mw.html.create('div'):addClass('tierGroup')
    if index ~= numberOfTiers then 
    	tierGroup:addClass('tierUnderline')
    end

    -- iterate over tokens in current tier, sperrated by ',' character
    for token in string.gmatch(currentTier, '([^,]+)') do
      character = token
      local characterLabel = mw.html.create('div')
      characterLabel:node(frame:expandTemplate{ title = 'Character Label', args = { GAME, character, size='32px' } }):done()
      tierGroup:node(characterLabel):done()
    end
    html:node(tierGroup)
    html:done()
  end

  -- close the entire tier list
  html:done()

  return html
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