Module:Merchandise
From The Obey Me Wiki
Description: Used to add merchandise links/images within tables
local cardList = {} function cardList.add(frame) -- iterate input into array local contact = {} for i = 1, 110 do contact[i] = frame:getParent().args[i] end local cardName = "" -- formats card name for i = 1, table.getn(contact) do cardName = contact[i] if string.find(cardName, "\n\n") then cardName = string.gsub(cardName, "\n\n", "") else cardName = string.gsub(cardName, "\n", "") end if string.find(cardName, " %(Casual%)") then contact[i] = "[[" .. cardName .. "|" .. string.gsub(cardName, " %(Casual%)", "<nowiki>[Casual]</nowiki>") .. "]]" else contact[i] = "[[" .. cardName .. "]]" end end -- starts the table local html = '<div class="flex-container">\n' local imageName = '' -- starting from first element of the array for card = 1, table.getn(contact), 10 do -- opens a new row html = html .. "\n" -- iterates between 1~10 for count = 0, 9 do imageName = string.gsub(string.gsub(frame:getParent().args[card + count], ":", " -"), "?", " -") html = html .. "<div class=\"merchflex\"><small><span class=\"desktop-ver\">[[File:" .. string.gsub(imageName, "\n", "") .. ".png|center|160px|class=cardimage|link=" .. string.gsub(frame:getParent().args[card + count], "\n", "") .. "]]</span>\n<span class=\"mobile-ver\">[[File:" .. string.gsub(imageName, "\n", "") .. ".png|center|150px|class=cardimage|link=" .. string.gsub(frame:getParent().args[card + count], "\n", "") .. "]]</span>\n" .. contact[card + count] .. "</small></div>\n" if card + count + 1 > table.getn(contact) then break end end -- completes one row of card html = html .. "\n" end return html .. "</div>" end return cardList --[[File:{{{1}}}.png|center|class="cardlistimage"|link={{{1}}}]]