FANDOM


--
-- Module:EpisodeTitle
--
-- The purpose of this module is to return title info for an episode
-- given just the season and episode number.
-- 
-- Usage: {{#invoke:EpisodeTitle|GetTitle|{{{1}}}|{{{2}}}}|{{{3}}}}
--        where {{{1}}} is the season number and {{{2}}} is the episode number
-- 
-- Options for {{{3}}}:
--   Null/default: return entire "Season X Episode Y: <Chapter> (Z)" title
--   index: return just the "(Z)" index
--   arc:   return the <Chapter> name without "Chapter XYZ: " in front
--   chap: return <Chapter> name with "Chapter XYZ:" in front
-- 
 
local p = {}
 
function p.GetTitle( frame )
	local season  = frame.args[1]
	local episode = frame.args[2]
	local option  = frame.args[3]
	local outputTxt = ''
	local refid   = 'Error: season number'
	local title   = 'Error: episode number'
	local ftitle  = 'Error: episode number'
	local index   = 'Error: index number'
 
	episode = tonumber( episode )
	if (season == '1') then
		refid = episode
		if (episode == 0) then title = 'Prologue'
		elseif (episode <= 5) then
			title = 'A Girl with a God\'s Name'
			ftitle = 'Chapter 1: A Girl with a God\'s Name'
			index = episode
		elseif (episode <= 11) then
			title = 'The Queen and the Bum'
			ftitle = 'Chapter 2: The Queen and the Bum'
			index = episode - 5
		elseif (episode <= 20) then
			title = 'The Sorrow of Loss'
			ftitle = 'Chapter 3: The Sorrow of Loss'
			index = episode - 11
		elseif (episode <= 26) then
			title = 'AAA Magician'
			ftitle = 'Chapter 4: AAA Magician'
			index = episode - 20
		elseif (episode <= 35) then
			title = 'The Golden Knight'
			ftitle = 'Chapter 5: The Golden Knight'
			index = episode - 26
		elseif (episode <= 42) then
			title = 'The Past I Yearn For'
			ftitle = 'Chapter 6: The Past I Yearn For'
			index = episode - 35
		elseif (episode <= 50) then
			title = 'Half (半)'
			ftitle = 'Chapter 7: Half (半)'
			index = episode - 42
		elseif (episode <= 57) then
			title = 'The Wavering King'
			ftitle = 'Chapter 8: The Wavering King'
			index = episode - 50
		elseif (episode <= 63) then
			title = 'Rival'
			ftitle = 'Chapter 9: Rival'
			index = episode - 57
		elseif (episode <= 83) then
			title = 'The Night it Rained Fire'
			ftitle = 'Chapter 10: The Night it Rained Fire'
			index = episode - 63
		elseif (episode <= 88) then
			title = 'The Power of the Name'
			ftitle = 'Chapter 11: The Power of the Name'
			index = episode - 83
		elseif (episode <= 100) then
			title = 'Lies for You'
			ftitle = 'Chapter 12: Lies for You'
			index = episode - 88
		end
	elseif (season == '2') then
		refid = '2-' .. episode
		if (episode == 0) then title = 'Season 2 Prologue'
		elseif (episode <= 5) then
			title = 'Lost'
			ftitle = 'Chapter 13: Lost'
			index = episode
		elseif (episode <= 12) then
			title = 'Blood'
			ftitle = 'Chapter 14: Blood'
			index = episode - 5
		elseif (episode <= 20) then
			title = 'The Weapon of a God'
			ftitle = 'Chapter 15: The Weapon of a God'
			index = episode - 12
		elseif (episode <= 26) then
			title = 'Caution'
			ftitle = 'Chapter 16: Caution'
			index = episode - 20
		elseif (episode <= 33) then
			title = 'Reflection'
			ftitle = 'Chapter 17: Reflection'
			index = episode - 26
		elseif (episode <= 40) then
			title = 'The Test of the Sword'
			ftitle = 'Chapter 18: The Test of the Sword'
			index = episode - 33
		elseif (episode <= 50) then
			title = 'Rift'
			ftitle = 'Chapter 19: Rift'
			index = episode - 40
		elseif (episode <= 57) then
			title = 'Grudge'
			ftitle = 'Chapter 20: Grudge'
			index = episode - 50
		elseif (episode <= 70) then
			title = 'Frozen Tears'
			ftitle = 'Chapter 21: Frozen Tears'
			index = episode - 57
		elseif (episode <= 80) then
			title = 'The One Standing Before Me'
			ftitle = 'Chapter 22: The One Standing Before Me'
			index = episode - 70
		elseif (episode <= 88) then
			title = 'The Good'
			ftitle = 'Chapter 23: The Good'
			index = episode - 80
		elseif (episode <= 95) then
			title = 'Taboo'
			ftitle = 'Chapter 24: Taboo'
			index = episode - 88
		elseif (episode <= 100) then
			title = 'That Which Cannot be Grasped or Held'
			ftitle = 'Chapter 25: That Which Cannot be Grasped or Held'
			index = episode - 95
		elseif (episode <= 106) then
			title = 'Outsider'
			ftitle = 'Chapter 26: Outsider'
			index = episode - 100
		elseif (episode <= 112) then
			title = 'Last Resort'
			ftitle = 'Chapter 27: Last Resort'
			index = episode - 106
		elseif (episode <= 120) then
			title = 'Emergency'
			ftitle = 'Chapter 28: Emergency'
			index = episode - 112
		elseif (episode <= 126) then
			title = 'Isle of Myths'
			ftitle = 'Chapter 29: Isle of Myths'
			index = episode - 120
		elseif (episode <= 134) then
			title = 'Falling Petals'
			ftitle = 'Chapter 30: Falling Petals'
			index = episode - 126
		elseif (episode <= 164) then
			title = 'Your Justice and Mine'
			ftitle = 'Chapter 31: Your Justice and Mine'
			index = episode - 134
		elseif (episode <= 173) then
			title = 'Loser'
			ftitle = 'Chapter 32: Loser'
			index = episode - 164
		elseif (episode <= 177) then
			title = 'Asha'
			ftitle = 'Chapter 33: Asha'
			index = episode - 173
		elseif (episode <= 180) then
			title = 'What Remains'
			ftitle = 'Chapter 34: What Remains'
			index = episode - 177
		end
    elseif (season == '3') then
		refid = '3-' .. episode
		if (episode == 0) then title = 'Season 3 Prologue'
		elseif (episode <= 5) then
			title = 'Return'
			ftitle = 'Chapter 35: Return'
			index = episode
		elseif (episode <= 13) then
			title = 'Another Beginning'
			ftitle = 'Chapter 36: Another Beginning'
			index = episode - 5
		elseif (episode <= 500) then
			title = 'Threat'
			ftitle = 'Chapter 37: Threat'
			index = episode - 13
        end
    end
 
    if (option == 'index') then	return (index) end
 
    if (option == 'arc') then return (title) end
 
    if (option == 'chap') then return (ftitle) end
 
    if (option == 'short') then
        if (season == '1') then
    		outputTxt = 'Ep.'	.. episode .. ': '
    	else
    		outputTxt = 'Ep.' .. season .. '-' .. episode .. ': '
		end
    else
        outputTxt = 'Season ' .. season .. ' Episode ' .. episode .. ': '
    end
 
    if (title == 'Half (半)') then
        outputTxt = outputTxt .. 'Half&nbsp;(半)&nbsp;-&nbsp;' .. index
    elseif (episode == 0) then
        outputTxt = outputTxt .. title
    else
        outputTxt = outputTxt .. title .. ' (' .. index ..')'
    end
    return (outputTxt)
end
 
return p
--[[Category:Lua modules]]

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.