Module:ItemLevel

--[=[ --LUA script to display items with level/status -- --Parameters: --   1: Type = Item Type --             "C" = Character --             "I" = Character Icon (Icon only, without background) --             "X" = Costume --             "A" = Attraction --             "F" = Float --   2: Collection = Collection Name (optional) --             For costumes = Character Name --   3: Items = list of items seperated by dollar sigh ($) --             item = "item name,level" --             if level = X, display blank/grey icon --             if level is missing, means level 0 --   4: item image size (default 40px) --   5: collection image size (default 1.25 * item size) --]=]

local p = {}

function p.dispItems(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 iType = tArgs[1] or "C" local collection = tArgs[2] or "" local itemList = tArgs[3] or "" local iSize = tonumber(tArgs[4]) or 40 local cSize = tonumber(tArgs[5]) or math.floor(iSize * 1.25) iType = iType:gsub("^%s*(.)%s*$", "%1")

if not mw.ustring.match(iType, "^[CIXAF]$") then return "Error: Unknown Type" end

local suffix = ""

if iType == "C" then suffix = "-side" end

if iType == "I" then iType = "C" end

local outText = ""

collection = collection:gsub("^%s*(.-)%s*$", "%1")

if collection ~= "" then if iType == "X" then outText = "[[File:C-"                   .. mw.ustring.gsub(mw.ustring.lower(collection),                        "[':%,%.]", "")                    .. ".png|link="                    .. collection                    .. "|"                    .. cSize                    .. "px|"                    .. collection                    .. "]] ― " else outText = "[[File:Cc-"                   .. mw.ustring.gsub(mw.ustring.lower(collection),                        "[':%,%.]", "")                    .. "-l.png|link=:Category:"                    .. collection                    .. "|"                    .. cSize                    .. "px|"                    .. collection                    .. "]] ― " end end

itemList = itemList:gsub("^%s*(.-)%s*$", "%1")

local space = "" local prefix = ""

if iType == "C" then prefix = "[[File:C-"   elseif iType == "A" then        prefix = "[[File:Ba-"    else        prefix = "[[File:Pf-"    end

for item in mw.text.gsplit(itemList, "%s*%$%s*") do

local iName, iLevel = mw.ustring.match(item,                            "^([^,]-)%s*,%s*(.-)$")

local welcomed = true

if not iName then iName = item iLevel = 0 else iLevel = tonumber(iLevel) if not iLevel then welcomed = false iLevel = 0 end end

if iType == "X" then outText = outText .. space

if not welcomed then outText = outText .. "" end outText = outText .. ""                           .. iName                            .. "" if not welcomed then outText = outText .. " "           end space = " • " elseif iType == "F" then local filePart = string.gsub(string.lower(iName),"[':%,%.]","")

if not welcomed then filePart = "?" end

outText = outText .. space .. prefix .. filePart .. ".png|link=" .. iName .. " Float|" .. iSize .. "px|" .. iName .. " Float]]"

space = " " else local filePart = string.gsub(string.lower(iName),"[':%,%.]","")

if not welcomed then filePart = "?" suffix = "" end

outText = outText .. space .. prefix .. filePart .. suffix .. ".png|link=" .. iName .. "|"                   .. iSize .. "px|" .. iName

if iLevel > 0 and mw.ustring.match(iType, "[CA]") then outText = outText .. " (Level "                       .. iLevel                        .. ")" end

outText = outText .. "]]"           space = " " end end

return outText end

return p

-- --