Module:ItemCollection

-- -- LUA script to get Collection Icon for Character

-- Parameters: -- 1: Character Name -- 2: Icon Size -- --

local p = {}

local collectionData = mw.loadData( 'Module:CharacterCollection/data' )

function p.getCollection(frame)

local tArgs

if frame == mw.getCurrentFrame then fParent = frame:getParent tArgs = fParent.args

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

local character = tArgs[1] or "" local size = tArgs[2] if not size or size == "" then size = "50" end

character = mw.ustring.gsub(character, "^%s*(.-)%s*$", "%1") or '' character = mw.ustring.lower(character)

local collectionFile = "" local space = "" local collections = {}

for cName in mw.text.gsplit(character, "%s*!%s*") do

if collectionData[cName] then local coll = collectionData[cName]

if not collections[coll] then collectionFile = collectionFile .. space .. "[[File:cc-"                   .. mw.ustring.gsub(mw.ustring.lower(coll), " ", "_")                    .. "-l.png|x"                    .. size                    .. "px|"                    .. coll                    .. "|link=Category:"                    .. coll                    .. "]]" space = " "

collections[coll] = 1 end end end

return collectionFile end

return p