FANDOM


-- 
-- This module is simply used to list all episodes
-- in which a particular character has appeared
-- and/or was mentioned.
-- 
 
local p = {}
 
local characterdat = mw.loadData( 'Module:CharApp/charappdat' )
 
function p.cData( frame )
    local release = frame.args[1]
    local EpNumber = 0
    local outputTxt  = ""
    local a = {}
 
    -- Grab the episode identifier number (EpNumber).
    EpNumber = tonumber( release )
 
    -- Go through charappdat and find all characters with EpNumber.
 
    -- List the characters who appeared in this episode in alphabetical order.
    outputTxt = "Appears in this episode:<br />"
 
    for i, _ in pairs( characterdat ) do  -- Go through the name keys.
        for _, g in pairs( characterdat[i].appearances ) do
            if g == tonumber( LinkNumber ) then
                table.insert( a, i )  -- Put the names into a temporary array.
            end
        end
    end
    table.sort( a )  -- Sort the names in alphabetical order (by first name)
    for _, n in ipairs( a ) do
        outputTxt = outputTxt .. "&nbsp;&nbsp;[[".. n .. "]]" .. "<br />"
    end
 
    -- List the characters who were mentioned only.
    a = {}  -- Clear the array so we can use it again.
    outputTxt = outputTxt .. "<br />Mentioned or referenced only:<br />"
    -- List the characters who were only mentioned in this episode in alphabetical order.
    for i, _ in pairs( characterdat ) do
        for _, g in pairs( characterdat[i].references ) do
            if g == tonumber( LinkNumber ) then
                table.insert( a, i )
            end
        end
    end
    table.sort( a )
    for _, n in ipairs( a ) do
        outputTxt = outputTxt .. "&nbsp;&nbsp;[[".. n .. "]]" .. "<br />"
    end
 
    return outputTxt .. "<br />"
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.