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] local file = mw.ustring.gsub(coll, "[\,\.]", "") file = mw.ustring.gsub(file, " ", "_") file = mw.ustring.lower(file)

if not collections[coll] then collectionFile = collectionFile .. space .. "cc-"                   .. file                    .. "-l.png" space = " "

collections[coll] = 1 end end end

return collectionFile end

return p

-- --