Module:Shop

From Inkipedia, the Splatoon wiki
Revision as of 13:37, 27 February 2024 by Exaskliri (talk | contribs) (post-7.0.0 Shelly/Donny are now solo in each of Ammo Knights' Inkopolis branch)

Displays an inline shop icon with a link text.

Parameters

game Named, required. The abbreviation of icon's game of origin. Must be one of the following:
  • S for Splatoon.
  • S2 for Splatoon 2.
  • S3 for Splatoon 3.
name Named, required. The English name of the shop.
  • Ammo Knights (Inkopolis) (while game=S3) for Shelly/Donny solo icon.
  • Ammo Knights (Duo) (while game=S3) for Shelly and Donny pair icon.
icononly Named, optional. If present and "true", the link text will be omitted.
size Named, optional. The width of the icon in pixels (do not include px). Defaults to 24 if absent.

Examples

Markup

{{Shop|game=S|name=Ammo Knights}}<br />
{{Shop|game=S3|name=Naut Couture}}<br />
{{Shop|game=S3|name=Ammo Knights|icononly=true|size=64}}<br />
{{Shop|game=S3|name=Ammo Knights (Inkopolis)|size=48}}

Output

Script error: The function "invokeFromTemplate" does not exist.
Script error: The function "invokeFromTemplate" does not exist.
Script error: The function "invokeFromTemplate" does not exist.
Script error: The function "invokeFromTemplate" does not exist.


local p = {}

local specificFileName	=	{
	["S"]	=	{},
	["S2"]	=	{
		["SplatNet 2"]	=	"S2 Icon SplatNet Gear Shop.png",
	},
	["S3"]	=	{
		["Crab-N-Go"]					=	"S3 Icon Staff.png",
		["SplatNet 3"]					=	"SplatNet 3 Shop.svg",
		["Ammo Knights (Inkopolis)"]	=	"S3 Icon Shelly Donny Solo.png",
		["Ammo Knights (Duo)"]			=	"S3 Icon Shelly Donny Duo.png",
	},
}

local specificLink	=	{
	["Ammo Knights (Splatsville)"]	=	"Ammo Knights",
	["Ammo Knights (Inkopolis)"]	=	"Ammo Knights",
	["SplatNet 2"]					=	"SplatNet 2#Shop",
	["SplatNet 3"]					=	"SplatNet 3#Shop",
}

local specificDisplayText	=	{
	["Ammo Knights (Splatsville)"]	=	"Ammo Knights",
	["Ammo Knights (Inkopolis)"]	=	"Ammo Knights",
}

function p.main(frame)
	local args		= frame:getParent().args
	local game		= args["game"]
	local name		= args["name"]
	local icononly	= args["icononly"]
	local size		= args["size"]
	return p.getShopIcon(game, name, icononly, size)
end

function p.getShopIcon(game, name, icononly, size)
	game = string.upper(game)
	local fileName		= specificFileName[game][name] or string.format("%s Icon %s.png", game, name)
	local link			= specificLink[name] or name
	local displayText	= specificDisplayText[name] or name
	local result
	if not size then size = 24 end
	
	result = string.format("[[File:%s|%dpx|link=%s]]", fileName, size, link)
	if not icononly then result = result..string.format(" [[%s|%s]]", link, displayText) end
	
	return result
end

return p