Editing Module:Mapcheck
Jump to navigation
Jump to search
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) | ||
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 | end | ||
mapsize = '' | mapsize = '' | ||
if frame.args.size then | if frame.args.size then | ||
mapsize = ' ('..frame.args.size..')' | mapsize = '('..frame.args.size..')' | ||
end | end | ||
compile = '' | compile = '' | ||
none = '** | none = '***' | ||
filelevels = {' '} | filelevels = {' '} | ||
if not frame.args.underground or frame.args.underground == 'enabled | if not frame.args.underground or frame.args.underground == 'enabled' then | ||
table.insert(filelevels, ' underground ') | table.insert(filelevels, ' underground ') | ||
end | end | ||
for _, filelevel in pairs(filelevels) do | for _, filelevel in pairs(filelevels) do | ||
for _, filesize in pairs({'tiny', 'small', 'medium', 'large', 'huge | 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 = | filename = frame.args.name..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'}} | ||
Line 42: | Line 27: | ||
end | end | ||
if fileexists == 'yes' then | if fileexists == 'yes' then | ||
none = '' | |||
dimensions = getDimensions(filename) | |||
compile = compile..'[[:file:'..filename..'|'..filesize..underground..'('..dimensions..')'..']], ' | compile = compile..'[[:file:'..filename..'|'..filesize..underground..'('..dimensions..')'..']], ' | ||
elseif filetype == 'png' then | elseif filetype == 'png' then | ||
Line 58: | Line 37: | ||
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 | compile = '[['..maplink..frame.args.name..']]'..mapsize..none..': '..compile | ||
return compile | return compile | ||
end | end | ||
Line 114: | Line 45: | ||
-- if map.file.width then | -- if map.file.width then | ||
-- if map.file.height then | -- if map.file.height then | ||
return map.file. | return map.file.height..'x'..map.file.width | ||
-- end | -- end | ||
-- end | -- end |