Module:Item

Revision as of 22:57, 15 October 2024 by Billy Mitchell (talk | contribs) (Created page with "local getArgs = require('Module:Arguments').getArgs local p = {} function p.main(frame) local args = getArgs(frame) local game = args[1]:lower() local item = args[2]:lower() local itemData = require('Module:Data/Item/' .. game).item local iconPage = mw.title.makeTitle('Module', 'Data/Icon/' .. game) local iconData = {} if iconPage.exists then iconData = require('Module:Data/Item/' .. game)["icon"] end local link = "" local itemIcon = "" if itemData[item]["i...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Documentation

Designed to be part of a template like so:

{{#invoke:Item|main|{{{1}}}|{{{2}}}}}

Parameter 1 is the game abbreviation and parameter 2 is the item name. This module will output the item icon and name together. If parameter 2 is an emdash, it outputs an emdash.

See also: Template:Item/Documentation


local getArgs = require('Module:Arguments').getArgs
local p = {}

function p.main(frame)
	local args = getArgs(frame)
	local game = args[1]:lower()
	local item = args[2]:lower()
	local itemData = require('Module:Data/Item/' .. game).item
	local iconPage = mw.title.makeTitle('Module', 'Data/Icon/' .. game)
	local iconData = {}
	if iconPage.exists then
		iconData = require('Module:Data/Item/' .. game)["icon"]
	end
	local link = ""
	local itemIcon = ""
	if itemData[item]["icon"] then
		itemIcon = itemData[item]["icon"]
	end
	if iconData[itemIcon] then
		link = iconData[itemIcon]
	end
	if itemData[item]["link"] then
		link = " [[" .. itemData[item]["link"] .. "|" .. itemData[item]["name"] .. "]]"
	else
		link = " [[" .. itemData[item]["name"] .. "]]"
	end
	while link:sub(1,1) == " " do
		link = link:sub(2)
	end
	return link
end

return p