Module:Equipment

local p = {} local h = {}

local File = require("Module:File") local Franchise = require("Module:Franchise") local utilsArg = require("Module:UtilsArg") local utilsCargo = require("Module:UtilsCargo") local utilsTable = require("Module:UtilsTable")

function h.err(errMsg, warnMsg) local utilsError = require("Module:UtilsError") return utilsError.error(errMsg, warnMsg) end

function p.Main(frame) local args, err = utilsArg.parse(frame:getParent.args, p.Templates["Equipment"]) if err then return "", err.categoryText end local tableName = args.game .. "ItemProperties" -- For now, there are -- different cargo tables per game, e.g. one for BotW, one for TotK local equipmentTypeQuery = utilsCargo.query(tableName, "type", {		where = "_pageName = '" .. utilsCargo.escape(args.equipment) .. "'",	})

local suffix = "" if #equipmentTypeQuery == 0 then if not string.find(args.equipment, "Arrow") then return h.err("Invalid game/equipment combination") end -- Arrows are a special case, are classified as Bow even if		-- they are not in the Cargo table and have a pluralized link suffix = "s" equipmentTypeQuery = { { type = "Bow" } } end local equipmentType = equipmentTypeQuery[1].type local icon = File.gameImage(args.game, equipmentType, "Icon", {		size = "x18px",	})

local html = mw.html.create("small") :wikitext(icon .. " " .. args.equipment .. "" .. suffix) return tostring(html) end

p.Templates = { ["Equipment"] = { description = "Displays a piece of equipment alongside its type icon.", purpose = "Displays a piece of equipment alongside its type icon.", params = { [1] = {				name = "game", required = true, enum = Franchise.enum, type = "string", desc = "A game code.", trim = true, nilIfEmpty= true, },			[2] = {				name = "equipment", required = true, type = "string", desc = "The equipment's name.", tim = true, nilIfEmpty = true, },		},		examples = { {				desc = "Blue Boko Reaper", args = {"TotK", "Blue Boko Reaper"}, },			{				desc = "Master Sword", args = {"BotW", "Master Sword"} },		},	}, }

return p