Module:Korok Seeds

From Zelda Wiki, the Zelda encyclopedia
Jump to navigation Jump to search
This is the main module for the following templates:
local p = {}

local DataTable = require("Module:Data Table")
local Franchise = require("Module:Franchise")
local Term = require("Module:Term")
local utilsArg = require("Module:UtilsArg")
local utilsTable = require("Module:UtilsTable")

function p.Main(frame)
	local args = utilsArg.parse(frame:getParent().args, p.Templates["Korok Seeds"])
	local rows = DataTable.parseRows(args.cells or {})

	for i in ipairs(rows) do
		local typeSwitcher
		if rows[i].cells[2] == "Traveling Korok Duo" then
			typeSwitcher = "Korok Seed 2"
		else
			typeSwitcher = "Korok Seed"
		end
		local icon = string.format("[[File:ZW %s %s.png|link= Korok Seed Puzzle]]", args.game, typeSwitcher)
		local link = Term.link(rows[i].cells[2], args.game)
		rows[i].cells[2] = icon.."<br/>"..link
	end
	
	local dataTable = DataTable.printTable(rows, {
		game = args.game,
		columns = {"Korok [Image:Korok:x120px]", "Type [Nowrap]", "Coordinates [Nowrap]", "Notes [Description]"},
		optionalColumns = {3},
	})
	return dataTable
end

p.Templates = {
	["Korok Seeds"] = {
		params = {
			game = {
				required = true,
				desc = "A [[Data:Franchise|game code]].",
				type = "string",
				enum = Franchise.enum(),
			},
			["..."] = {
				name = "cells",
				type = "content",
				trim = true,
			},
		},
		tableParams = {
			{
				name = "korok",
				desc = "An image of the Korok.",
				tags = {"Image"},
			},
			{
				name = "type",
				desc = "The Korok Seed Puzzle type.",
				tags = {"Term"},
			},
			{
				name = "coordinates",
				desc = "Precise location of the Korok Seed Puzzle.",
				optional = true,
				tags = {"Nowrap"},
			},
			{
				name = "notes",
				desc = "Notes on how to locate the Korok in the area.",
				tags = {"Description"},
			},
		},
	},
}

return p