Module:Mapcheck: Difference between revisions

From Heroes 3 wiki
Jump to navigation Jump to search
(Created page with "local p = {} --p stands for package function p.mapcheck(frame) compile = '' for _, filetype in pairs({'png', 'gif', 'jpg'}) do for _, filesize in pairs({'tiny', 'small', 'medium', 'large', 'huge'}) do for _, filelevel in pairs({' ', ' underground '}) do filename = frame.args.scenario..filelevel..'map '..filesize..'.'..filetype fileresult = frame:expandTemplate{title = 'exist', args = {'file:'..filename, 'yes'}} if fileresult == 'yes' then compile...")
 
No edit summary
Line 3: Line 3:
function p.mapcheck(frame)
function p.mapcheck(frame)
compile = ''
compile = ''
for _, filetype in pairs({'png', 'gif', 'jpg'}) do
for _, filetype in pairs({' ', ' underground '}) do
for _, filesize in pairs({'tiny', 'small', 'medium', 'large', 'huge'}) do
for _, filesize in pairs({'tiny', 'small', 'medium', 'large', 'huge'}) do
for _, filelevel in pairs({' ', ' underground '}) do
for _, filelevel in pairs({'png', 'gif', 'jpg'}) do
filename = frame.args.scenario..filelevel..'map '..filesize..'.'..filetype
filename = frame.args.scenario..filelevel..'map '..filesize..'.'..filetype
fileresult = frame:expandTemplate{title = 'exist', args = {'file:'..filename, 'yes'}}
fileexists = frame:expandTemplate{title = 'exist', args = {'file:'..filename, 'yes'}}
if fileresult == 'yes' then
if fileexists == 'yes' then
compile = compile..filename..' : '..getDimensions(filename)..'<br>'
-- compile = compile..filename..' : '..getDimensions(filename)..'<br>'
dimensions = getDimensions(filename)
compile = compile..'[[file:'..filename..'|'..filesize..'('..dimensions..')'..']], '
else
compile = compile..'{{extLink|link=https://heroes.thelazy.net/index.php?title=Special:Upload&wpDestFile='..filename..'|title='..filesize..'(upload)}}, '
end
end
end
end
end
end
end
end
if compile == '' then
-- compile = string.sub(compile, string.len()-2)
compile = frame.args.scenario..' : none <br>'
compile = '[['..frame.args.scenario..']]: '..compile
end
return compile
return compile
end
end

Revision as of 01:24, 20 December 2023

Usage

{{#invoke:mapcheck|mapcheck|name=A New Day Tomorrow}}

local p = {} --p stands for package

function p.mapcheck(frame)
	compile = ''
	for _, filetype in pairs({' ', ' underground '}) do
		for _, filesize in pairs({'tiny', 'small', 'medium', 'large', 'huge'}) do
			for _, filelevel in pairs({'png', 'gif', 'jpg'}) do
				filename = frame.args.scenario..filelevel..'map '..filesize..'.'..filetype
				fileexists = frame:expandTemplate{title = 'exist', args = {'file:'..filename, 'yes'}}
				if fileexists == 'yes' then
					-- compile = compile..filename..' : '..getDimensions(filename)..'<br>'
					dimensions = getDimensions(filename)
					compile = compile..'[[file:'..filename..'|'..filesize..'('..dimensions..')'..']], '
				else
					compile = compile..'{{extLink|link=https://heroes.thelazy.net/index.php?title=Special:Upload&wpDestFile='..filename..'|title='..filesize..'(upload)}}, '
				end
			end
		end
	end
	-- compile = string.sub(compile, string.len()-2)
	compile = '[['..frame.args.scenario..']]: '..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