Module:Size

From Kerbal Space Program 2 Modding Wiki
Revision as of 06:06, 1 March 2025 by KiwiShark (talk | contribs) (added 3,4,5X tags)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

This module is used by Template:Size to match the supplied argument to the formatted size tag string.

The main function getSize accepts the first argument passed to Template:Size and returns the formatted size tag.


local p = {}
local getArgs = require('Module:Arguments').getArgs

function p.getSize(frame)
	-- Get arguments from the invoke
	-- frameOnly is used to ignore additional arguments passed when 
	-- Template:Size is called from an infobox, for example
	local args = getArgs(frame, {frameOnly = true}) 
	-- Pass arguments to the helper function
	size = p._getSize(args)
	return size
end

function p._getSize(args)
	-- Take the arg as the size tag label
	sizeTag = args[1]
	size = ""
	
	-- Match the tag to the proper formatted string to display
	if sizeTag == "XS" then size = "<code><b><font color=#E04949>XS</font></b></code>" end
	if sizeTag == "SM" then size = "<code><b><font color=#E0A400>SM</font></b></code>" end
	if sizeTag == "MD" then size = "<code><b><font color=#93E000>MD</font></b></code>" end
	if sizeTag == "LG" then size = "<code><b><font color=#00E0A8>LG</font></b></code>" end
	if sizeTag == "XL" then size = "<code><b><font color=#49ABE0>XL</font></b></code>" end
	if sizeTag == "2X" then size = "<code><b><font color=#A978DA>2X</font></b></code>" end
	if sizeTag == "3X" then size = "<code><b><font color=#EF88E0>3X</font></b></code>" end
	if sizeTag == "4X" then size = "<code><b><font color=#C5B8BE>4X</font></b></code>" end
	if sizeTag == "5X" then size = "<code><b><font color=#FFFFFF>5X</font></b></code>" end
	
	return size
end

return p