Module:Mini Cards showcase
From The Obey Me Wiki
local cardList = {} function cardList.add(frame) -- iterate input into array local contact = {} for i = 1, 100 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, "%(Pride%)") then contact[i] = "[[" .. cardName .. "|" .. string.sub(cardName, 1, string.find(cardName, "%(Pride%)") - 2) .. "]] [[File:Pride.png|10px]]" elseif string.find(cardName, "%(Greed%)") then contact[i] = "[[" .. cardName .. "|" .. string.sub(cardName, 1, string.find(cardName, "%(Greed%)") - 2) .. "]] [[File:Greed.png|10px]]" elseif string.find(cardName, "%(Envy%)") then contact[i] = "[[" .. cardName .. "|" .. string.sub(cardName, 1, string.find(cardName, "%(Envy%)") - 2) .. "]] [[File:Envy.png|10px]]" elseif string.find(cardName, "%(Wrath%)") then contact[i] = "[[" .. cardName .. "|" .. string.sub(cardName, 1, string.find(cardName, "%(Wrath%)") - 2) .. "]] [[File:Wrath.png|10px]]" elseif string.find(cardName, "%(Lust%)") then contact[i] = "[[" .. cardName .. "|" .. string.sub(cardName, 1, string.find(cardName, "%(Lust%)") - 2) .. "]] [[File:Lust.png|10px]]" elseif string.find(cardName, "%(Gluttony%)") then contact[i] = "[[" .. cardName .. "|" .. string.sub(cardName, 1, string.find(cardName, "%(Gluttony%)") - 2) .. "]] [[File:Gluttony.png|10px]]" elseif string.find(cardName, "%(Sloth%)") then contact[i] = "[[" .. cardName .. "|" .. string.sub(cardName, 1, string.find(cardName, "%(Sloth%)") - 2) .. "]] [[File:Sloth.png|10px]]" else contact[i] = "[[" .. cardName .. "]]" end end -- starts the table local html = '<table style="width:100%; text-align:center; border: none !important; line-height: 16px;">\n' -- starting from first element of the array for card = 1, table.getn(contact), 10 do -- opens a new row html = html .. "<tr>\n" -- iterates between 1~10 for count = 0, 9 do html = html .. "<td style=\"width:10%;\">[[File:" .. string.gsub(frame:getParent().args[card + count], "\n", "") .. "_Mini.png|64px|center|link=" .. string.gsub(frame:getParent().args[card + count], "\n", "") .. "]]</td>\n" if card + count + 1 > table.getn(contact) then break end end -- closes the image row, starts the name row html = html .. "</tr><tr>\n" for count = 0, 9 do html = html .. "<td valign=\"top\"><small>" .. contact[card + count] .. "</small></td>\n" if card + count + 1 > table.getn(contact) then break end end -- completes one row of card html = html .. "</tr>\n" end return html .. "</table>" end return cardList --[[File:{{{1}}}_Mini.png|64px|center|link={{{1}}}]]