Module:Imahero/test: Difference between revisions

From Heroes 3 wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 5: Line 5:
for _, filetype in pairs({'png', 'gif', 'jpg'}) do
for _, filetype in pairs({'png', 'gif', 'jpg'}) do
for _, filesize in pairs({'tiny', 'small', 'medium', 'large', 'huge'}) do
for _, filesize in pairs({'tiny', 'small', 'medium', 'large', 'huge'}) do
filename = frame.args.scenario..' map '..filesize..'.'..filetype
for _, filelevel in pairs({' ', ' underground '}) do
ufilename = frame.args.scenario..' underground map '..filesize..'.'..filetype
filename = frame.args.scenario..filelevel..'map '..filesize..'.'..filetype
compile = compile..frame:expandTemplate{title = 'exist', args = {'file:'..filename, getDimensions(filename)}}
fileresult = frame:expandTemplate{title = 'exist', args = {'file:'..filename, 'yes'}}
compile = compile..frame:expandTemplate{title = 'exist', args = {'file:'..ufilename, getDimensions(ufilename)}}
if fileresult == 'yes' then
compile = compile..'* '..filename..' : '..getDimensions(filename)
end
end
end
end
end
end
Line 16: Line 19:
function getDimensions(filename)
function getDimensions(filename)
map = mw.title.makeTitle(6, filename)
map = mw.title.makeTitle(6, filename)
if map.file.width then
-- if map.file.width then
if map.file.height then
-- if map.file.height then
     return map.file.height..'x'..map.file.width
     return map.file.height..'x'..map.file.width
end
-- end
end
-- end
return ''
-- return ''
end
end



Revision as of 00:07, 20 December 2023

See usage on user:imahero/test.


local p = {} --p stands for package

function p.testing(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 = compile..'* '..filename..' : '..getDimensions(filename)
				end
			end
		end
	end
	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

function p.test( frame )
    return frame
end

langObject = mw.getLanguage( 'simple' )

function p.language( frame )
    return langObject:getCode()
end

function p.arrow( frame )
    return langObject:getArrow( frame.args.direction )
end

return p