Module:Appearances

From Japari Library, the Kemono Friends Wiki
Jump to navigation Jump to search

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

local getArgument = require('Module:Arguments').getArgument

local p = {}

function p.Main(frame)
	local args = frame.args
	--Defining the page title
	local pageName = mw.title.getCurrentTitle().text
	
	--Defining each title's abbreviation parameter and year override parameter if necessary
	local nexon = args['KFN']
	local manga = args['KFM']
	local s1 = args['KFS1']
	local gb = args['KFGB']
	local kiseki = args['PnK']
	local s2gb = args['KFE']
	local aLaCarte = args['KFCALC']
	local aLaCarteOverride = args['KFCALC_Year']
	local cafeAnthology = args['KFJC']
	local manjuAnthology = args['KFJM']
	local busAnthology = args['KFJB']
	local radioAnthology = args['KFYKT']
	local cafe1 = args['JC1']
	local cafe2 = args['JC2']
	local stage1 = args['SPKF']
	local stage1Override = args['SPKF_Year']
	local collabShorts = args['KFCS']
	local alarm1 = args['KFA']
	local pavilion = args['KFP']
	local pavilionOverride = args['KFP_Year']
	local elove = args['eLove']
	local gokko = args['KFPPG']
	local pppSky = args['PPPS']
	local festival = args['KFF']
	local festivalOverride = args['KFF_Year']
	local ona = args['WTJP']
	local onaOverride = args['WTJP_Year']
	local picross = args['KFPC']
	local safariDrive = args['SD']
	local stage2 = args['SPKF2']
	local kf2 = args['KF2']
	local kf2Manga = args['KF2M']
	local alarm2 = args['KFA2']
	local chokotto = args['CAKF3']
	local chokottoOverride = args['CAKF3_Year']
	local friendsBeat = args['FB']
	local kf3 = args['KF3']
	local kf3Override = args['KF3_Year']
	local kf3Planet = args['KF3PT']
	local kf3PlanetOverride = args['KF3PT_Year']
	local japariStage = args['JS']
	local japariStageOverride = args['JS_Year']
	local xxx = args['XXX']
	local miracleDialies = args['MD']
	local pachislot = args['PKF']
	local kingdom = args['KFK']
	local kingdomOverride = args['KFK_Year']
	local japariStage2 = args['JS2']
	
	function checkExists(value)
		if value == '' then
			return false
		elseif value ~= '' then
			return value
		end
	end
	
	--Checking if certain media types return a result to add a header
	if nexon ~= '' or alarm1 ~= '' or pavilion ~= '' or gokko ~= '' or festival ~= '' or picross ~= '' 
	or alarm2 ~= '' or kf3 ~= '' or kf3Planet ~= '' or pachislot ~= '' or kingdom ~= '' then
		game = '\n|-\n!colspan=4|Games'
	else
		game = ''
	end
	if manga ~= '' or aLaCarte ~= '' or kf2Manga ~= '' then
		printwork = '\n|-\n!colspan=4|Print Works'
	else
		printwork = ''
	end
	if cafe1 ~= '' or cafe2 ~= '' or pppSky ~= '' or safariDrive ~= '' or friendsBeat ~= '' 
	or xxx ~= '' or miracleDialies ~= '' then
		music = '\n|-\n!colspan=4|Music'
	else
		music = ''
	end
	if s1 ~= '' or collabShorts ~= '' or ona ~= '' or kf2 ~= '' or chokotto ~= '' then
		animation = '\n|-\n!colspan=4|Animation'
	else
		animation = ''
	end
	if stage1 ~= '' or elove ~= '' or stage2 ~= '' or japariStage ~= '' or japariStage2 ~= '' then
		stage = '\n|-\n!colspan=4|Stage Plays'
	else
		stage = ''
	end
	
	--Definining the header
	output = '{| class="wikitable"\n|+ Appearances in \'\'Kemono Friends\'\' media\n!Year\n!Media\n!Role\n!First Appearance'
	
	--Big block of media-related outputs
	local x = false
	local nexonRow = ''
	if nexon ~= '' then
		local nexonFirst = args['KFN_First']
		nexonRow = '\n|-\n|2015\n|[[Kemono Friends (2015 Mobile Game)|\'\'Kemono Friends\'\']]\n|[[' .. pageName .. '/Nexon Game|↪]] ' .. nexon .. '\n|' .. nexonFirst
		x = true
	end
	
	local alarm1Row = ''
	if alarm1 ~= '' then
		alarm1Row = '\n|-\n|2017\n|\'\'[[Kemono Friends Alarm]]\'\'\n|' .. alarm1 .. '\n!'
		x = true
	end
	
	local pavilionRow = ''
	if pavilion ~= '' then
		pavilionRow = '\n|-\n|' .. (checkExists(pavilionOverride) or '2018') .. '\n|\'\'[[Kemono Friends Pavilion]]\'\'\n|[[' .. pageName .. '/Pavilion|↪]] ' .. pavilion .. '\n!'
		x = true
	end
	
	local gokkoRow = ''
	if gokko ~= '' then
		gokkoRow = '\n|-\n|2018\n|\'\'[[Kemono Friends Puzzle Puzzle Gokko]]\'\'\n|' .. gokko .. '\n!'
		x = true
	end
	
	local festivalRow = ''
	if festival ~= '' then
		local festivalFirst = args['KFF_First']
		festivalRow = '\n|-\n|' .. (checkExists(festivalOverride) or '2018') .. '\n|\'\'[[Kemono Friends Festival]]\'\'\n|[[' .. pageName .. '/Festival|↪]] ' .. festival .. '\n|' .. festivalFirst
		x = true
	end
	
	local picrossRow = ''
	if picross ~= '' then
		picrossRow = '\n|-\n|2018\n|\'\'[[Kemono Friends Picross]]\'\'\n|' .. picross .. '\n!'
		x = true
	end
	
	local alarm2Row = ''
	if alarm2 ~= '' then
		alarm2Row = '\n|-\n|2019\n|\'\'[[Kemono Friends Alarm 2]]\'\'\n|' .. alarm2 .. '\n!'
		x = true
	end
	
	local kf3Row = ''
	if kf3 ~= '' then
		local kf3First = args['KF3_First']
		kf3Row = '\n|-\n|' .. (checkExists(kf3Override) or '2019') .. '\n|\'\'[[Kemono Friends 3]]\'\'\n|[[' .. pageName .. '/KF3|↪]] ' .. kf3 .. '\n|' .. kf3First
		x = true
	end
	
	local kf3PlanetRow = ''
	if kf3Planet ~= '' then
		local kf3PlanetFirst = args['KF3PT_First']
		kf3PlanetRow = '\n|-\n|' .. (checkExists(kf3PlanetOverride) or '2019') .. '\n|\'\'[[Kemono Friends 3: Planet Tours]]\'\'\n|[[' .. pageName .. '/KF3|↪]] ' .. kf3Planet .. '\n|' .. kf3PlanetFirst
		x = true
	end
	
	local pachislotRow = ''
	if pachislot ~= '' then
		pachislotRow = '\n|-\n|2022\n|\'\'[[Pachislot Kemono Friends]]\'\'\n|[[' .. pageName .. '/Pachislot|↪]] ' .. pachislot .. '\n!'
		x = true
	end
	
	local kingdomRow = ''
	if kingdom ~= '' then
		local kingdomFirst = args['KFK_First']
		kingdomRow = '\n|-\n|' .. (checkExists(kingdomOverride) or '2022') .. '\n|\'\'[[Kemono Friends Kingdom]]\'\'\n|[[' .. pageName .. '/Kingdom|↪]] ' .. kingdom .. '\n|' .. kingdomFirst
		x = true
	end
	
	local mangaRow = ''
	if manga ~= '' then
		local mangaFirst = args['KFM_First']
		mangaRow = '\n|-\n|2015\n|\'\'[[Kemono Friends: Welcome to Japari Park!]]\'\'\n|[[' .. pageName .. '/Manga|↪]] ' .. manga .. '\n|' .. mangaFirst
		x = true
	end
	
	local aLaCarteRow = ''
	if aLaCarte ~= '' then
		local alaCarteFirst = args['KFCALC_First']
		aLaCarteRow = '\n|-\n|' .. (checkExists(aLaCarteOverride) or '2017') .. '\n|\'\'[[Kemono Friends: Comic À La Carte]]\'\'\n|' .. aLaCarte .. '\n|' .. alaCarteFirst
		x = true
	end
	
	local cafeAnthologyRow = ''
	if cafeAnthology ~= '' then
		cafeAnthologyRow = '\n|-\n|2017\n|\'\'[[Kemono Friends Anthology Comic: Japari Café]]\'\'\n|' .. cafeAnthology .. '\n!'
		x = true
	end

	local manjuAnthologyRow = ''
	if manjuAnthology ~= '' then
		manjuAnthologyRow = '\n|-\n|2017\n|\'\'[[Kemono Friends Comic Anthology: Japari Bun]]\'\'\n|' .. manjuAnthology .. '\n!'
		x = true
	end
	
	local busAnthologyRow = ''
	if busAnthology ~= '' then
		busAnthologyRow = '\n|-\n|2017\n|\'\'[[Kemono Friends Dengeki Comic Anthology: Japari Bus]]\'\'\n|' .. busAnthology .. '\n!'
		x = true
	end
	
	local radioAnthologyRow = ''
	if radioAnthology ~= '' then
		radioAnthologyRow = '\n|-\n|2018\n|\'\'[[Kemono Friends Comic x RADIO Anthology: Yonde! Kitte! Taanoshii!!!]]\'\'\n|' .. radioAnthology .. '\n!'
		x = true
	end
	
	local kf2MangaRow = ''
	if kf2Manga ~= '' then
		local kf2MangaFirst = args['KF2M_First']
		kf2MangaRow = '\n|-\n|2019\n|[[Kemono Friends 2 (Manga)|\'\'Kemono Friends 2\'\' (Manga)]]\n|[[' .. pageName .. '/Season 2|↪]] ' .. kf2Manga .. '\n|' .. kf2MangaFirst
		x = true
	end
	
	local gbRow = ''
	if gb ~= '' then
		gbRow = '\n|-\n|2017\n|\'\'[[Kemono Friends Official Guidebooks]]\'\'\n|' .. gb .. '\n!'
		x = true
	end
	
	local kisekiRow = ''
	if kiseki ~= '' then
		kisekiRow = '\n|-\n|2018\n|\'\'[[Project no Kiseki]]\'\'\n|' .. kiseki .. '\n!'
		x = true
	end
	
	local s2gbRow = ''
	if s2gb ~= '' then
		s2gbRow = '\n|-\n|2019\n|\'\'[[Kemono Friends Encyclopedia]]\'\'\n|' .. s2gb .. '\n!'
		x = true
	end
	
	local cafe1Row = ''
	if cafe1 ~= '' then
		cafe1Row = '\n|-\n|2017\n|[[Japari Café (Album)|\'\'Japari Café\'\']]\n|' .. cafe1 .. '\n!'
		x = true
	end
	
	local cafe2Row = ''
	if cafe2 ~= '' then
		cafe2Row = '\n|-\n|2017\n|\'\'[[Japari Café 2]]\'\'\n|' .. cafe2 .. '\n!'
		x = true
	end
	
	local pppSkyRow = ''
	if pppSky ~= '' then
		pppSkyRow = '\n|-\n|2018\n|\'\'[[PPP in the Sky!]]\'\'\n|' .. pppSky .. '\n!'
		x = true
	end
	
	local safariDriveRow = ''
	if safariDrive ~= '' then
		safariDriveRow = '\n|-\n|2019\n|\'\'[[Safari Drive]]\'\'\n|' .. safariDrive .. '\n!'
		x = true
	end
	
	local friendsBeatRow = ''
	if friendsBeat ~= '' then
		friendsBeatRow = '\n|-\n|2019\n|\'\'[[FRIENDS BEAT!]]\'\'\n|' .. friendsBeat .. '\n!'
		x = true
	end
	
	local xxxRow = ''
	if xxx ~= '' then
		xxxRow = '\n|-\n|2020\n|\'\'[[×・×・×]]\'\'\n|' .. xxx .. '\n!'
		x = true
	end
	
	local miracleDialiesRow = ''
	if miracleDialies ~= '' then
		miracleDialiesRow = '\n|-\n|2020\n|\'\'[[Miracle Dialies]]\'\'\n|' .. miracleDialies .. '\n!'
		x = true
	end
	
	local s1Row = ''
	if s1 ~= '' then
		local s1First = args['KFS1_First']
		s1Row = '\n|-\n|2017\n|[[Kemono Friends (2017 Anime)|\'\'Kemono Friends\'\' (2017 Anime)]]\n|[[' .. pageName .. '/Anime|↪]] ' .. s1 .. '\n|' .. s1First
		x = true
	end
	
	local collabShortsRow = ''
	if collabShorts ~= '' then
		local collabShortsFirst = args['KFCS_First']
		collabShortsRow = '\n|-\n|2017\n|\'\'[[Kemono Friends Collaborative Shorts]]\'\'\n|[[' .. pageName .. '/Anime|↪]] ' .. collabShorts .. '\n|' .. collabShortsFirst
		x = true
	end

	local onaRow = ''
	if ona ~= '' then
		local onaFirst = args['WTJP_First']
		onaRow = '\n|-\n|' .. (checkExists(onaOverride) or '2017') .. '\n|[[Welcome to Japari Park (2018 ONA)|\'\'Welcome to Japari Park\'\' (2018 ONA)]]\n|[[' .. pageName .. '/Nexon Game|↪]] ' 
		.. ona .. '\n|' .. onaFirst
		x = true
	end
	
	local kf2Row = ''
	if kf2 ~= '' then
		local kf2First = args['KF2_First']
		kf2Row = '\n|-\n|2017\n|\'\'[[Kemono Friends 2]]\'\'\n|[[' .. pageName .. '/Season 2|↪]] ' 
		.. kf2 .. '\n|' .. kf2First
		x = true
	end
	
	local chokottoRow = ''
	if chokotto ~= '' then
		local chokottoFirst = args['CAKF3_First']
		chokottoRow = '\n|-\n|' .. (checkExists(chokottoOverride) or '2017') .. '\n|\'\'[[Chokotto Anime Kemono Friends 3]]\'\'\n|[[' .. pageName .. '/KF3|↪]] ' 
		.. chokotto .. '\n|' .. chokottoFirst
		x = true
	end
	
	local stage1Row = ''
	if stage1 ~= '' then
		stage1Row = '\n|-\n|' .. (checkExists(stage1Override) or '2018').. '\n|\'\'[[Stage Play "Kemono Friends"]]\'\'\n|[[' .. pageName .. '/Stage Play|↪]] ' 
		.. stage1 .. '\n!'
		x = true
	end
	
	local eloveRow = ''
	if elove ~= '' then
		eloveRow = '\n|-\n|2018\n|\'\'[[=LOVE Stage Project "Kemono Friends"]]\'\'\n|[[' .. pageName .. '/Stage Play|↪]] ' 
		.. elove .. '\n!'
		x = true
	end
	
	local stage2Row = ''
	if stage2 ~= '' then
		stage2Row = '\n|-\n|2018\n|\'\'[[Stage Play "Kemono Friends 2" ~Kemonos of the Snowy Night~]]\'\'\n|[[' .. pageName .. '/Stage Play|↪]] ' 
		.. stage2 .. '\n!'
		x = true
	end
	
	local japariStageRow = ''
	if japariStage ~= '' then
		japariStageRow = '\n|-\n|' .. (checkExists(japariStageOverride) or '2019') .. '\n|\'\'[[Stage Play Kemono Friends "JAPARI STAGE!" ~Big Ears and Small Miracles~]]\'\'\n|[[' .. pageName .. '/Stage Play|↪]] ' 
		.. japariStage .. '\n!'
		x = true
	end
	
	local japariStage2Row = ''
	if japariStage2 ~= '' then
		japariStage2Row = '\n|-\n|2018\n|\'\'[[Stage Play "Kemono Friends" JAPARI STAGE! ~I Could Hear Your Footsteps Once Again~]]\'\'\n|[[' .. pageName .. '/Stage Play|↪]] ' 
		.. japariStage2 .. '\n!'
		x = true
	end
	
	if x == true then
		output = output 
		.. game .. nexonRow .. alarm1Row .. pavilionRow .. gokkoRow .. festivalRow .. picrossRow .. alarm2Row .. kf3Row .. kf3PlanetRow .. pachislotRow .. kingdomRow
		.. animation .. s1Row .. collabShortsRow .. onaRow .. kf2Row .. chokottoRow
		.. printwork .. mangaRow .. gbRow .. aLaCarteRow .. cafeAnthologyRow .. manjuAnthologyRow .. busAnthologyRow .. radioAnthologyRow .. kisekiRow .. s2gbRow .. kf2MangaRow
		.. stage  .. stage1Row .. eloveRow .. stage2Row .. japariStageRow .. japariStage2Row
		.. music .. cafe1Row .. cafe2Row .. pppSkyRow .. safariDriveRow .. friendsBeatRow .. xxxRow .. miracleDialiesRow
		.. '\n|}'
	elseif x == false then
		output = output .. '\n|-\n|colspan=4|This Friend has yet to appear in any official media.\n|}'
	end
	
	return output
end

return p