Editing Module:Mapcheck

Jump to navigation Jump to search
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.

Latest revision Your text
Line 2: Line 2:


function p.mapcheck(frame)
function p.mapcheck(frame)
if not mw.site.server:find('heroes.thelazy.net') and not mw.site.server:find('fandom.com') then
return ''
end
if mw.title.getCurrentTitle().text:find('Maps/') then
return previewOnly(frame)
end
if mw.title.getCurrentTitle().text == 'Minimaps' then
return previewMinimapOnly(frame)
end
maplink = ''
maplink = ''
if frame.args.map_link then
if frame.args.map_link then
maplink = frame.args.map_link..'|'
maplink = frame.args.map_link..'|'
end
imagelink = frame.args.name
if frame.args.imagelink then
imagelink = frame.args.imagelink
end
mapsize = ''
if frame.args.size then
mapsize = ' ('..frame.args.size..')'
end
end
compile = ''
compile = ''
none = '**'
none = '***'
none_u = ''
filelevels = {' '}
filelevels = {' '}
if not frame.args.underground or frame.args.underground == 'enabled' or frame.args.underground == '' then
if frame.args.underground == 'enabled' then
table.insert(filelevels, ' underground ')
table.insert(filelevels, ' underground ')
none_u = '**'
end
end
for _, filelevel in pairs(filelevels) do
for _, filelevel in pairs(filelevels) do
for _, filesize in pairs({'tiny', 'small', 'medium', 'large', 'huge', 'auto', 'fullauto'}) do
for _, filesize in pairs({'tiny', 'small', 'medium', 'large', 'huge'}) do
for _, filetype in pairs({'png', 'gif', 'jpg'}) do
for _, filetype in pairs({'png', 'gif', 'jpg'}) do
filename = imagelink..filelevel..'map '..filesize..'.'..filetype
filename = frame.args.scenario..filelevel..'map '..filesize..'.'..filetype
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'}}
underground = ''
if filelevel == ' underground ' then
if filelevel == ' underground ' then
underground = '(u)'
underground = '(u)'
end
end
if fileexists == 'yes' then
if fileexists == 'yes' then
if filelevel == ' underground ' then
none = ''
underground = '(u)'
dimensions = getDimensions(filename)
none_u = ''
else
none = ''
end
-- dimensions = getDimensions(filename)
dimensions = 'view'
compile = compile..'[[:file:'..filename..'|'..filesize..underground..'('..dimensions..')'..']], '
compile = compile..'[[:file:'..filename..'|'..filesize..underground..'('..dimensions..')'..']], '
elseif filetype == 'png' then
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}}..', '
compile = compile..frame:expandTemplate{title='extLink', args={link='https://heroes.thelazy.net/index.php?title=Special:Upload&wpDestFile='..filename, title=filesize..underground}}..', '
end
end
Line 58: Line 33:
end
end
compile = mw.ustring.sub(compile, 0, string.len(compile)-2)
compile = mw.ustring.sub(compile, 0, string.len(compile)-2)
compile = '[['..maplink..frame.args.name..']]'..mapsize..none..none_u..': '..compile
compile = '[['..maplink..frame.args.scenario..']]'..none..': '..compile
return compile
end
 
function previewOnly(frame)
imagelink = frame.args.name
if frame.args.imagelink then
imagelink = frame.args.imagelink
end
compile = ''
filelevels = {' '}
if not frame.args.underground or frame.args.underground == 'enabled' or frame.args.underground == '' then
table.insert(filelevels, ' underground ')
end
for _, filelevel in pairs(filelevels) do
for _, filesize in pairs({'tiny', 'small', 'medium', 'large', 'huge', 'auto', 'fullauto'}) do
for _, filetype in pairs({'png', 'gif', 'jpg'}) do
filename = imagelink..filelevel..'map '..filesize..'.'..filetype
filename = string.gsub(filename, ' ', '_')
fileexists = frame:expandTemplate{title = 'exist', args = {'file:'..filename, 'yes'}}
if fileexists == 'yes' then
compile = compile..'[[file:'..filename..'|'..'66px'..']]'
end
end
end
end
return compile
end
 
function previewMinimapOnly(frame)
imagelink = frame.args.name
if frame.args.imagelink then
imagelink = frame.args.imagelink
end
compile = ''
filelevels = {' '}
if not frame.args.underground or frame.args.underground == 'enabled' or frame.args.underground == '' then
table.insert(filelevels, ' underground ')
end
for _, filelevel in pairs(filelevels) do
for _, filetype in pairs({'png', 'gif', 'jpg'}) do
filename = imagelink..filelevel..'minimap.'..filetype
filename = string.gsub(filename, ' ', '_')
fileexists = frame:expandTemplate{title = 'exist', args = {'file:'..filename, 'yes'}}
if fileexists == 'yes' then
compile = compile..'[[file:'..filename..'|'..'66px'..']]'
end
end
end
return compile
return compile
end
end
Line 114: Line 41:
-- if map.file.width then
-- if map.file.width then
-- if map.file.height then
-- if map.file.height then
     return map.file.width..'x'..map.file.height
     return map.file.height..'x'..map.file.width
-- end
-- end
-- end
-- end
Please note that all contributions to Heroes 3 wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!
Cancel Editing help (opens in new window)

Template used on this page: