Module:CharacterAvatar

-- -- LUA script replacement for wikitext template -- -- -- -- Parameters: -- 1: Character Name -- 2: Event / IP version -- -- The list of available versions is kept in the module data -- to avoid the expensive function "ifexist" -- -- Plain version is returned if Event version is not in data. --

local p = {}

local avatarData = mw.loadData( 'Module:CharacterAvatar/data' )

function p.getAvatar(frame) local tArgs = frame:getParent

if not(tArgs.args[1]) then tArgs = frame end

local character = mw.ustring.lower(tArgs.args[1] or "") local eventName = mw.ustring.lower(tArgs.args[2] or nil)

local avatarFile = "[[File:c-" .. character

if eventName and avatarData[character] and avatarData[character][eventname] then avatarFile = avatarFile .. "-" .. avatarData[character][eventname] end

avatarFile = avatarFile .. ".png|x50px|" .. character .. "|link=" .. Character .. "]]"

return avatarFile end

return p