Module:ItemLevel

--[=[ --LUA script to display items with level/status -- --Parameters: --   1: Type = Item Type --             "C" = Character --             "D" = Dress (Costume) --             "A" = Attraction --             "F" = Float --   2: Collection = Collection Name (optional) --             For costumes = Character Name --   3: Items = list of items seperated by ! --             item = "item name,level" --             if level = 0, display blank grey icon --   4: item image size (default 40px) --   5: collection image size (default 50px) --]=]

local p = {}

-- local tokenData = mw.loadData( 'Module:CharacterToken/data' )

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 = tArgs[4] or "40" local cSize = tArgs[5] or "50"

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

local outText = ""

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

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

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

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*(%d+)$")

iLevel = tonumber(iLevel)

if not iName or iName == "" then iName = "?" end

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

if iLevel == 0 then outText = outText .. " "           end outText = outText .. ""                           .. iName                            .. "" if iLevel == 0 then outText = outText .. " "           end space = " • " else local filePart = string.gsub(string.lower(iName),"[':%,%.]","")

if iLevel == 0 then filePart = "?" end

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

if iType == "C" and iLevel > 0 then outText = outText .. " (Level "                       .. iLevel                        .. ")" elseif iType == "F" then outText = outText .. " Float" end

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

return outText end

return p