Module:Amiibo

local p = {} p.main = function(frame) local args = frame:getParent.args local amiiboName = args['name'] or args[1] or '' local size = args['size'] or tonumber(args[2]) or 24 local section = args['section'] or amiiboName local text = args['text'] or nil -- Get the file extention; if unspecified or empty, use png. local ext = (args['ext'] or ) ==  and 'png' or string.lower(args['ext'])

-- Mapping table for amiibo name patterns to image file names. Order doesn't matter. -- Define 'text' if the display text after the icon is different to the amiibo's name. local amiiboMap = { -- Splatoon 1 {pattern = "Inkling Girl (Splatoon)", imageName = "S_amiibo_Inkling Girl", text = "Inkling Girl (Splatoon)"}, {pattern = "Inkling Girl (Lime Green)", imageName = "S_amiibo_Inkling Girl (Lime Green)", text = "Inkling Girl (Lime Green)"}, {pattern = "Inkling Girl (recolor)", imageName = "S_amiibo_Inkling Girl (Lime Green)", text = "Inkling Girl (Lime Green)"}, {pattern = "Inkling Girl", imageName = "S_amiibo_Inkling Girl", text = "Inkling Girl (Splatoon)"}, {pattern = "Inkling Boy (Splatoon)", imageName = "S_amiibo_Inkling Boy", text = "Inkling Boy (Splatoon)"}, {pattern = "Inkling Boy (Purple)", imageName = "S_amiibo_Inkling Boy (Purple)", text = "Inkling Boy (Purple)"}, {pattern = "Inkling Boy (recolor)", imageName = "S_amiibo_Inkling Boy (Purple)", text = "Inkling Boy (Purple)"}, {pattern = "Inkling Boy", imageName = "S_amiibo_Inkling Boy", text = "Inkling Boy (Splatoon)"}, {pattern = "Inkling Squid (Splatoon)", imageName = "S_amiibo_Inkling Squid", text = "Inkling Squid (Splatoon)"}, {pattern = "Inkling Squid (Orange)", imageName = "S_amiibo_Inkling Squid (Orange)", text = "Inkling Squid (Orange)"}, {pattern = "Inkling Squid (recolor)", imageName = "S_amiibo_Inkling Squid (Orange)", text = "Inkling Squid (Orange)"}, {pattern = "Inkling Squid", imageName = "S_amiibo_Inkling Squid", text = "Inkling Squid (Splatoon)"}, {pattern = "Callie", imageName = "S_amiibo_Callie"}, {pattern = "Marie", imageName = "S_amiibo_Marie"}, -- Splatoon 2 {pattern = "Inkling Girl (Splatoon 2)", imageName = "S2_amiibo_Inkling Girl", text = "Inkling Girl (Splatoon 2)"}, {pattern = "Inkling Girl 2", imageName = "S2_amiibo_Inkling Girl", text = "Inkling Girl (Splatoon 2)"}, {pattern = "Inkling Boy (Splatoon 2)", imageName = "S2_amiibo_Inkling Boy", text = "Inkling Boy (Splatoon 2)"}, {pattern = "Inkling Boy 2", imageName = "S2_amiibo_Inkling Boy", text = "Inkling Boy (Splatoon 2)"}, {pattern = "Inkling Squid (Splatoon 2)", imageName = "S2_amiibo_Inkling Squid", text = "Inkling Squid (Splatoon 2)"}, {pattern = "Inkling Squid 2", imageName = "S2_amiibo_Inkling Squid", text = "Inkling Squid (Splatoon 2)"}, {pattern = "Octoling Girl", imageName = "S2_amiibo_Octoling Girl"}, {pattern = "Octoling Boy", imageName = "S2_amiibo_Octoling Boy"}, {pattern = "Octoling Octopus", imageName = "S2_amiibo_Octoling Octopus"}, {pattern = "Marina", imageName = "S2_amiibo_Marina"}, {pattern = "Pearl", imageName = "S2_amiibo_Pearl"}, -- Splatoon 3 {pattern = "Inkling (Yellow)", imageName = "S3_amiibo_Inkling (Yellow)", text = "Inkling (Splatoon 3)"}, {pattern = "Octoling (Blue)", imageName = "S3_amiibo_Octoling (Blue)", text = "Octoling (Splatoon 3)"}, {pattern = "Smallfry", imageName = "S3_amiibo_Smallfry"}, {pattern = "Shiver", imageName = "S3_amiibo_Shiver"}, {pattern = "Frye", imageName = "S3_amiibo_Frye"}, {pattern = "Big Man", imageName = "S3_amiibo_Big Man"}, -- Others {pattern = "Inkling Girl (Super Smash Bros. Ultimate)", imageName = "SSBU_amiibo_Inkling Girl", text = "Inkling Girl (Super Smash Bros. Ultimate)"} }

-- Default to amiiboName if not found local imageName = amiiboName local amiiboText = nil

-- Iterate through the map to find the first matching pattern for _, mapping in ipairs(amiiboMap) do       if amiiboName == mapping.pattern then imageName = mapping.imageName amiiboText = mapping.text break end end

-- Construct the image link local imageLink = string.format('',                                   imageName, ext, size, size, amiiboName,                                    section)

local span = mw.html.create('span') span:css('width', size .. 'px') span:css('height', size .. 'px') span:css('text-align', 'center') span:css('display', 'inline-block') span:wikitext(imageLink) local output = tostring(span)

-- Append additional text if not icononly if args[2] ~= 'icononly' and args[3] ~= 'icononly' then text = text or amiiboText or amiiboName output = output .. '&#32;' ..  .. text ..  end

return output end

return p