Module:Profession clickpic

Revision as of 22:15, 26 November 2024 by BlackHawk (talk | contribs) (Created page with "-- <pre> local p = {} local pics = mw.loadData("Module:Profession clickpic/data"); function p.main(frame) local args = frame:getParent().args return p._main{ profession = args[1] or '', level = args[2], link = args.link, }; end local function unpackMainArgs(args, ...) if (select("#", ...) == 0 and type(args) == "table") then return args, args.profession, args.level; else return nil, args, ...; end end function p._main(...) local args, profession,...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Module documentation
This documentation is transcluded from Module:Profession clickpic/doc. [edit] [history] [purge]
This module does not have any documentation. Please consider adding documentation at Module:Profession clickpic/doc. [edit]
Module:Profession clickpic loads data from Module:Profession clickpic/data.
Module:Profession clickpic is required by Module:Profession info.

-- <pre>

local p = {}

local pics = mw.loadData("Module:Profession clickpic/data");

function p.main(frame)
	local args = frame:getParent().args

	return p._main{
		profession	= args[1] or '',
		level	= args[2],
		link	= args.link,
	};
end


local function unpackMainArgs(args, ...)
	if (select("#", ...) == 0 and type(args) == "table") then
		return args, args.profession, args.level;
	else
		return nil, args, ...;
	end
end


function p._main(...)
	local args, profession, level = unpackMainArgs(...);
	local file
	if type(profession) == 'string' and pics[profession:lower()] then
		file = pics[profession:lower()]
	else
		file = pics.stats
	end

	local ret = '[[File:'..file.image..'.png|21x21px|link='..((args and args.link) or file.link or '')..'|alt='..(file.link or '')..']]'
	if level then
		ret = level..' '..ret
	end
	
	return ret
end

return p