Module:MultiItems

local p = {} local util = require("Module:Utility")

function p.getItems(frame) local tArgs = util.getArgs(frame) local items = tArgs[1] or "" local prefix = tArgs[2] or "" local size = tArgs[3] local suffix = tArgs[4] or ""

if not size or size == "" then size = "50" end

items = mw.ustring.gsub(items, "^%s*(.-)%s*$", "%1") or '' -- check for !! (! at the end of item) -- replace with ^! -- ^ will be replaced back to ! before returning items = mw.ustring.gsub(items, "!!", "^!")

local itemsFile = "" local space = ""

for it in mw.text.gsplit(items, "%s*%$%s*") do

local lcIt = mw.ustring.gsub(it, "^([^%(]+)%s%(([^%d]+)%)$", "%1-%2")       if not lcIt then lcIt = it end

lcIt = mw.ustring.gsub(mw.ustring.lower(lcIt), "[':%,%.]", "")

itemsFile = itemsFile .. space .. "[[File:"                   .. prefix                    .. "-"                    .. lcIt                    .. ".png|x"                    .. size                    .. "px|link="                    .. it        if suffix and suffix ~= "" then            itemsFile = itemsFile .. " " .. suffix        end

itemsFile = itemsFile .. "]]"

space = " " end

-- replace back any ! (delimiter) changed earlier itemsFile = mw.ustring.gsub(itemsFile, "%^", "!")

return itemsFile end

return p

-- --