Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.
Revision as of 12:36, 10 October 2025 by Admin (talk | contribs) (Created page with "-- Module:Appearances -- Renders appearance lists and auto-adds categories for characters. -- Supports custom display text and category overrides. local p = {} -- Define all possible appearances and their default categories. local appearances = { ["Suikoden"] = "Characters in Suikoden", ["Suikoden II"] = "Characters in Suikoden II", ["Suikoden III"] = "Characters in Suikoden III", ["Suikoden IV"] = "Characters in Suikoden IV", ["Suikoden V"] = "Characters in Suiko...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Documentation for this module may be created at Module:Appearances/doc

-- Module:Appearances
-- Renders appearance lists and auto-adds categories for characters.
-- Supports custom display text and category overrides.

local p = {}

-- Define all possible appearances and their default categories.
local appearances = {
	["Suikoden"] = "Characters in Suikoden",
	["Suikoden II"] = "Characters in Suikoden II",
	["Suikoden III"] = "Characters in Suikoden III",
	["Suikoden IV"] = "Characters in Suikoden IV",
	["Suikoden V"] = "Characters in Suikoden V",
	["Suikoden Tactics"] = "Characters in Suikoden Tactics",
	["Genso Suikogaiden Vol.1"] = "Characters in Genso Suikogaiden Vol.1",
	["Genso Suikogaiden Vol.2"] = "Characters in Genso Suikogaiden Vol.2",
	["Genso Suikoden Card Stories"] = "Characters in Genso Suikoden Card Stories",
	["Genso Suikoden Tierkreis Hoshikuzu no Shiro"] = "Characters in Genso Suikoden Tierkreis Hoshikuzu no Shiro",
	["Suikoden Tierkreis"] = "Characters in Suikoden Tierkreis",
	["Pachislot Genso Suikoden"] = "Characters in Pachislot Genso Suikoden",
	["Genso Suikoden Tsumugareshi Hyakunen no Toki"] = "Characters in Genso Suikoden Tsumugareshi Hyakunen no Toki",
	["Suikoden STAR LEAP"] = "Characters in Suikoden STAR LEAP",
	["Konami Parody Comic Series Genso Suikoden"] = "Characters from Konami Parody Comic Series Genso Suikoden",
	["Genso Suikoden: Soul Eater 1"] = "Characters from Genso Suikoden Soul Eater",
	["Genso Suikoden: Soul Eater 3"] = "Characters from Genso Suikoden Soul Eater",
	["Genso Suikoden II: 1 (novel)"] = "Characters from the Genso Suikoden II novel",
	["Genso Suikoden II: 4 (novel)"] = "Characters from the Genso Suikoden II novel",
	["Genso Suikoden Short Story Collection 1"] = "Characters from Genso Suikoden Short Story Collection 1",
	["Genso Suikoden Short Story Collection 2"] = "Characters from Genso Suikoden Short Story Collection 2",
	["Genso Suikoden Short Story Collection 3"] = "Characters from Genso Suikoden Short Story Collection 3",
	["Genso Suikoden Short Story Collection 4"] = "Characters from Genso Suikoden Short Story Collection 4",
	["Genso Suikoden IV: 1 (novel)"] = "Characters from the Genso Suikoden IV novel",
}

-- Helper to trim whitespace
local function trim(s)
	return (s:gsub("^%s*(.-)%s*$", "%1"))
end

-- Renders a single appearance entry
local function renderEntry(name, display, category)
	name = trim(name)
	display = display or name
	category = category or appearances[name] or ("Characters in " .. name)

	return string.format("* [[%s|%s]] [[Category:%s]]", name, display, category)
end

-- Main entry point
function p.render(frame)
	local input = frame.args[1] or ""
	if input == "" then return "" end

	-- Split by comma
	local entries = mw.text.split(input, ",")
	local output = {}

	for _, entry in ipairs(entries) do
		entry = trim(entry)
		if entry ~= "" then
			-- Handle custom syntax: Game|Display|Category
			local parts = mw.text.split(entry, "|")
			local game = trim(parts[1] or "")
			local display = trim(parts[2] or "")
			local category = trim(parts[3] or "")

			if game ~= "" then
				table.insert(output, renderEntry(game, display ~= "" and display or nil, category ~= "" and category or nil))
			end
		end
	end

	return table.concat(output, "<br />\n")
end

return p