Module:CharacterAppearances

local p = {}

local totalShikarEps = 24

function getCharTable return {--'["Index"]' should match character's pagename; '= function' --PCs ["Valym"] = Valym, ["Scorpio"] = Scorpio, ["Ajax"] = Ajax, ["Nim Grimwillow"] = Nim, --NPCs ["Leander"] = Leander, ["Sunflower"] = Sunflower, --Test ["Infobox Character"] = InfoboxTest, } end

-- function Example	local appearanceTable = {		first = "1x1",		last = "1x1",		exclude = {			--"All episodes except..."		},		include = {			"1x0",		},	}	return appearanceTable end

-- PCs -- function Valym local appearanceTable = { first = "1x01", last = "Continuing", exclude = { "1x12x1", "1x12x2", "1x17", },		include = nil, }	return appearanceTable end

function Scorpio local appearanceTable = { first = "1x01", last = "1x14", exclude = { "1x12x1", "1x12x3", "1x15", "1x18", },		include = nil, }	return appearanceTable end

function Ajax local appearanceTable = { first = "1x01", last = "Continuing", exclude = { "1x12x2", "1x12x3", },		include = nil, }	return appearanceTable end

function Nim local appearanceTable = { first = "1x01", last = "Continuing", exclude = { "1x12x2", "1x12x3", "1x18", },		include = nil, }	return appearanceTable end

--NPCs -- function Leander --!Missing appearances! local appearanceTable = { first = "1x06", last = "1x12x4", exclude = nil, include = { "1x12x1", "1x12x2", "1x12x3", },	}	return appearanceTable end

function Sunflower --!Missing appearances! local appearanceTable = { first = "1x01", last = "", exclude = nil, include = {}, }	return appearanceTable end

-- End - function InfoboxTest local appearanceTable = { first = "1x01", last = "1x09", exclude = nil, include = { "1x04", "1x06", },	}	return appearanceTable end

function p.appearances(frame) local episode = require('Module:Ep') local characters = getCharTable local character = frame.args[1] if not isnotempty(characters[character]) then return " Undefined Appearances " end character = characters[character] if frame.args[2] == "First" then return episode.ep({args={character.first}}) elseif frame.args[2] == "Last" then return episode.ep({args={character.last}}) elseif frame.args[2] == "List" then local listedText = "" local listedEps = character.include if isnotempty(character.exclude) then listedEps = character.exclude listedText = listedText .. "All Episodes except: " end if isnotempty(listedEps) then local numListedEps = #listedEps listedText = listedText .. "" for i = 1, numListedEps do listedText = listedText .. "" .. episode.ep({args={listedEps[i]}}) .. "" end listedText = listedText .. "" end return listedText elseif frame.args[2] == "Count" then local totalCharEps = 0 if isnotempty(character.include) then totalCharEps = totalCharEps + #character.include if isnotempty(character.first) then totalCharEps = totalCharEps + 1 end if isnotempty(character.last) then totalCharEps = totalCharEps + 1 end elseif isnotempty(character.exclude) then totalCharEps = totalShikarEps - #character.exclude end return totalCharEps end return "" end

-- function to determine that a variable has a value function isnotempty(s) return s ~= nil and s~= '' end

return p