Dota 2 Wiki
Register
Advertisement

Documentation for Module:Team icon Jump to code ↴ [ edit | purge ]

Reality Rift icon
▶️ Planeshift.
The documentation for this module can be found at Template:Team icon.
You may be forwarded to another wiki language, in case a translation is not available.


Dependencies

local cargo = mw.ext.cargo
local getArgs = require( 'Module:Arguments' ).main
local error = require( 'Module:Error' ).main
local p = {}

function p.main( frame )
	local args = getArgs()
	return p._main( args )
end

function p._main( args )
	if args[1] then
		local size = args[2] or '40px'
		local icon = 'File:Team icon Default.png'
	
		if pcall( p.cargo, args[1] ) then
			local result = p.cargo( args[1] )
			if result ~= '' then
				icon = 'File:' .. result
			end
		else
			local success, result = pcall( p.ifexist, 'File:Team icon ' .. args[1] .. '.png' )
			if success == true and result == true then
				icon = 'File:Team icon ' .. args[1] .. '.png'
			end
		end
	
		return '[[' .. icon .. '|' .. size .. '|link=' .. args[1] .. ']]'
	else
		return error( 'Check your input.' )
	end
end

function p.ifexist( file )
	return mw.title.new( file ).fileExists
end

function p.cargo( team )
	return cargo.query( 'professional_teams', 'CONCAT(icon)', { where='_pageName="' .. team .. '"', groupBy='_pageID' } )[1]['CONCAT(icon)']
end

return p
Advertisement