VALORANT Esports Wiki
Advertisement

To edit the documentation or categories for this module, click here.


local p = {}

function p.TeamImage ( frame )
	local args = frame 
	if frame == mw.getCurrentFrame() then
		args = require( 'Module:ProcessArgs').norm()
	else
		frame = mw.getCurrentFrame()
	end
	
	-- Everything above here is just to make the module know what arguments it has
	
	local tnames = mw.loadData( 'Module:Teamnames' ) -- Teamnames is where all of the data is stored
	local userinput = mw.ustring.lower(args[1] or '') -- Just define a new variable that's either the user's team input or an empty string, but lowercase
	local size = args['size'] or '123px' -- Default the size to 123px unless the user input something else
	local namevars = tnames[userinput] -- so we go through tnames (Module:Teamnames) and try to find the user's input there
	local logo = '' -- Default the logo to be the empty string for now
	
	if not namevars then -- namvars won't exist if userinput isn't located in Module:Teamnames
		link = '' -- in this case make the link empty string too
	elseif type(namevars) == 'string' then -- If we found a string, e.g. tsm = "team solomid" then the user gave us a shortname
		namevars = tnames[namevars] -- so now look up with the new input, which is actually the correct one, in tnames
		logo = namevars.link:gsub("+", " ") -- + is an unallowed character in filenames, so e.g. Szef+6 needs to be changed to Szef 6
		link = namevars.link -- link becomes the link variable
	else -- in this case namevars is actually a table, so we have the right thing
		logo = namevars.link:gsub("+", " ") -- again, + is an unallowed character
		link = namevars.link -- let the link be the right thing
	end
	
	local text = '[[File:' .. logo .. 'logo square.png|' .. size .. '|link=' .. link ..']]' -- so if logo is empty string, we just give the file logo square.png; and if link is empty string, it won't link to anything. Otherwise it'll be the right thing.
	return text -- return the logo
end

return p
Advertisement