Module:MultiItems

local p = {}

local util = require("Module:Utility") local EC = require("Module:EC").getEC local TOK = require("Module:CharacterToken").getTokenDirect local CHEST = require("Module:EnchantedChest").getChest local cData = mw.loadData( 'Module:ItemCollection/data' )

local tItem = {}

local function ITEM(iData, iName, size) local conv = { ["ch"] = "cp", ["cos"] = "cp", }

local iDisp = iName:gsub("^([^%(]-)%/([^%(]-)$", "%2")

if size=="L" then return table.concat({"", (iDisp or iName), ""}) else size = size + 5 local fname = mw.ustring.gsub(mw.ustring.lower(iName), "[':\"%,%.]", "")		fname = fname:gsub(" ", "_")		if iData[2] == "pf" then			fname = fname:gsub("_float$", "")		else			fname = fname:gsub("^([^%(]-)%/([^%(]-)$", "%1-%2")			fname = mw.ustring.gsub(fname, "^([^%(]-) *%(([^%(]-)%)$", "%1_%2")		end

local tItemData = {	"", "", "" }

if iData["C"] and cData["Categories"][iData["C"]] then local category = iData["C"] tItemData[1] = '' tItemData[16] = ' ' tItem[3] = ' ' end

return table.concat(tItemData) end end

function p.getOneItem(item, count, size, withName, tRewards, type) if not item or not count or count=="" then return "" end local nCount = 2 if not tostring(count):match("%d[,/-]%d") then nCount = tonumber(count) or 0 count = util.th_comma(nCount) end

tItem = {"", (type and "" or (" " .. count)), (withName and " " or ""), "", "",			(withName and " " or ""), }

local iName = item local iData = cData.Items[iName] if iData == nil then iData = cData["Items"][iName:match("(.+)%-%d+$")] end

if iName:match("Chests") and not iName:match("Wacky Lunch Chests") then tItem[1] = CHEST({item, (size or 35)}) if withName then tItem[4] = CHEST({item, "L"}) if nCount > 1 then tItem[5] = "s" end end item = "CHEST-" .. item elseif iData and iData[2] then tItem[1] = ITEM(iData, iName, (size or 42)) tItem[2] = "" if withName then tItem[4] = ITEM(iData, item, "L") end item = "ZITM-" .. item elseif item:match("^EC") then tItem[1] = EC({item, nil, nil, (size and "I" or "E"), (size or 35)}) if withName then tItem[4] = EC({item, "L", S=(nCount==1)}) end else tItem[1] = TOK(item, (size or 35)) if withName then tItem[4] = TOK(item, "L") if nCount > 1 then tItem[5] = "s" end end item = "TOK-" .. item end

if nCount == 0 then tItem[2] = " ?" end

if tRewards and type then if not tRewards[item] then tRewards[item] = {I = table.concat(tItem)} end if not tRewards[item][type] then tRewards[item][type] = nCount else tRewards[item][type] = (tRewards[item][type] + nCount) end return tRewards end

return table.concat(tItem) end

return p