@DeletedUser41170185 (talk | contribs) mNo edit summary |
@DeletedUser41170185 (talk | contribs) mNo edit summary |
||
Line 1: | Line 1: | ||
local cargo = mw.ext.cargo |
local cargo = mw.ext.cargo |
||
− | local getArgs = require( 'Module:Arguments' ). |
+ | local getArgs = require( 'Module:Arguments' ).getArgs |
local p = {} |
local p = {} |
||
function p.main( frame ) |
function p.main( frame ) |
||
− | + | local args = getArgs(frame, { |
|
+ | wrappers = { |
||
⚫ | |||
+ | 'Template:Team icon' |
||
+ | } |
||
+ | }) |
||
⚫ | |||
end |
end |
||
function p._main( args ) |
function p._main( args ) |
||
− | + | if args[1] then |
|
− | + | local name = args[1] |
|
− | + | local size = args[2] or '40px' |
|
− | + | local icon = 'File:Team icon Default.png' |
|
+ | |||
− | |||
− | + | local cargo_output = cargo.query( 'professional_teams', 'icon, name', { where='_pageName="' .. args[1] .. '"', groupBy='_pageID' } )[1] |
|
− | + | if cargo_output and cargo_output['icon'] ~= '' then |
|
− | + | name = cargo_output['name'] |
|
− | + | icon = 'File:' .. cargo_output['icon'] |
|
− | + | else |
|
− | + | local success, result = pcall( function( file ) return mw.title.new( file ).fileExists end, '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] .. '|' .. name .. ']]' |
|
− | + | else |
|
− | + | return error( 'Check your input', 0 ) |
|
− | + | end |
|
end |
end |
||
Revision as of 13:17, 20 April 2018
▶️
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' ).getArgs
local p = {}
function p.main( frame )
local args = getArgs(frame, {
wrappers = {
'Template:Team icon'
}
})
return p._main( args )
end
function p._main( args )
if args[1] then
local name = args[1]
local size = args[2] or '40px'
local icon = 'File:Team icon Default.png'
local cargo_output = cargo.query( 'professional_teams', 'icon, name', { where='_pageName="' .. args[1] .. '"', groupBy='_pageID' } )[1]
if cargo_output and cargo_output['icon'] ~= '' then
name = cargo_output['name']
icon = 'File:' .. cargo_output['icon']
else
local success, result = pcall( function( file ) return mw.title.new( file ).fileExists end, '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] .. '|' .. name .. ']]'
else
return error( 'Check your input', 0 )
end
end
return p