Module:Mapcheck: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 18: | Line 18: | ||
filename = string.gsub(filename, ' ', '_') | filename = string.gsub(filename, ' ', '_') | ||
fileexists = frame:expandTemplate{title = 'exist', args = {'file:'..filename, 'yes'}} | fileexists = frame:expandTemplate{title = 'exist', args = {'file:'..filename, 'yes'}} | ||
if filelevel == ' underground ' then | |||
underground = '(u)' | |||
end | |||
if fileexists == 'yes' then | if fileexists == 'yes' then | ||
none = '' | none = '' | ||
dimensions = getDimensions(filename) | dimensions = getDimensions(filename) | ||
compile = compile..'[[:file:'..filename..'|'..filesize..'('..dimensions..')'..']], ' | compile = compile..'[[:file:'..filename..'|'..filesize..underground..'('..dimensions..')'..']], ' | ||
elseif filetype == 'png' then | elseif filetype == 'png' then | ||
underground = '' | underground = '' | ||
compile = compile..frame:expandTemplate{title='extLink', args={link='https://heroes.thelazy.net/index.php?title=Special:Upload&wpDestFile='..filename, title=filesize..underground}}..', ' | compile = compile..frame:expandTemplate{title='extLink', args={link='https://heroes.thelazy.net/index.php?title=Special:Upload&wpDestFile='..filename, title=filesize..underground}}..', ' | ||
end | end |
Revision as of 02:31, 20 December 2023
Usage
{{#invoke:mapcheck|mapcheck|name=A New Day Tomorrow}}
local p = {} --p stands for package
function p.mapcheck(frame)
maplink = ''
if frame.args.map_link then
maplink = frame.args.map_link..'|'
end
compile = ''
none = '***'
filelevels = {' '}
if frame.args.underground == 'enabled' then
table.insert(filelevels, ' underground ')
end
for _, filelevel in pairs(filelevels) do
for _, filesize in pairs({'tiny', 'small', 'medium', 'large', 'huge'}) do
for _, filetype in pairs({'png', 'gif', 'jpg'}) do
filename = frame.args.scenario..filelevel..'map '..filesize..'.'..filetype
filename = string.gsub(filename, ' ', '_')
fileexists = frame:expandTemplate{title = 'exist', args = {'file:'..filename, 'yes'}}
if filelevel == ' underground ' then
underground = '(u)'
end
if fileexists == 'yes' then
none = ''
dimensions = getDimensions(filename)
compile = compile..'[[:file:'..filename..'|'..filesize..underground..'('..dimensions..')'..']], '
elseif filetype == 'png' then
underground = ''
compile = compile..frame:expandTemplate{title='extLink', args={link='https://heroes.thelazy.net/index.php?title=Special:Upload&wpDestFile='..filename, title=filesize..underground}}..', '
end
end
end
end
compile = mw.ustring.sub(compile, 0, string.len(compile)-2)
compile = '[['..maplink..frame.args.scenario..']]'..none..': '..compile
return compile
end
function getDimensions(filename)
map = mw.title.makeTitle(6, filename)
-- if map.file.width then
-- if map.file.height then
return map.file.height..'x'..map.file.width
-- end
-- end
-- return ''
end
return p