Module:Item Amount

local Franchise = require("Module:Franchise") local File = require("Module:File") local Term = require("Module:Term") local utilsArg = require("Module:UtilsArg") local utilsMarkup = require("Module:UtilsMarkup")

local p = {}

function p.Main(frame) local args, err = utilsArg.parse(frame:getParent.args, p.Templates["Item Amount"]) if err then return utilsMarkup.categories(err.categories) end return p.printItemAmount(args.game, args.amount, args.item, args.noText) end

function p.printItemAmount(game, amount, item, noText) local result = "" result = result .. File.icon(game, item, {		size = "32x32px",		link = noText and item or nil	}) result = result .. " × " .. amount if not noText then result = result .. " " .. Term.printTerm({			page = item,			game = game,			link = "link",			plural = amount > 1,		}) end return result end

p.Templates = { ["Item Amount"] = { purpose = "Displaying a quantity of a certain item.", format = "inline", paramOrder = {1, 2, 3, 4}, params = { [1] = {				name = "game", type = "string", required = true, enum = Franchise.enumGames, desc = "A game code." },			[2] = {				name = "amount", type = "number", required = true, desc = "The amount to display.", },			[3] = {				name = "item", type = "wiki-page-name", required = true, desc = "The name of an item. Specifically, the name of the wiki page on which the item is described.", },			[4] = {				name = "noText", type = "string", desc = "Entering anything in this field will output the result in an abbreviated form.", canOmit = true, },		},		boilerplate = { list = true, }	}, }

return p