Module:Shop: Difference between revisions

From Inkipedia, the Splatoon wiki
(adjusted specificFileName table so it requires both game and shop names)
m (added S blank table on specificFileName (fixes index nil))
Line 2: Line 2:


local specificFileName = {
local specificFileName = {
["S"] = {},
["S2"] = {
["S2"] = {
["SplatNet 2"] = "S2 Icon SplatNet Gear Shop.png",
["SplatNet 2"] = "S2 Icon SplatNet Gear Shop.png",

Revision as of 14:53, 5 February 2024

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"]	=	{
		["SplatNet 3"]	=	"SplatNet 3 Shop.svg",
	},
}

local specificLink	=	{
	["SplatNet 2"]	=	"SplatNet 2#Shop",
	["SplatNet 3"]	=	"SplatNet 3#Shop",
}

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)
	string.upper(game)
	local fileName	= specificFileName[game][name] or string.format("%s Icon %s.png", game, name)
	local link		= specificLink[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, name) end
	
	return result
end

return p