Kubera Wiki


672pages on
this wiki
Add New Page
-- This module is used by the Template:Episode infobox
-- to make a list of characters that have appeared
-- and/or were mentioned in a particular episode.
-- The episode numbers used in the data file charappdat
-- are the ones used on the Naver website to identify an
-- episode. E.g. the number for Episode 2-154 is 261.
-- Update 12-23-2015: Simplified the function to use
--   the release number instead of season + episode
local p = {}
local characterdat = mw.loadData( 'Module:CharApp/charappdat' )
function p.cData( frame )
    local release = frame.args[1]
    local LinkNumber = 0
    local outputTxt  = ""
    local a = {}
    local next = next  -- bind next to a local var for effiency
    -- Grab the episode identifier number (LinkNumber).
    LinkNumber = tonumber( release )
    -- Go through charappdat and find all characters with LinkNumber.
    -- List the characters who appeared in this episode in alphabetical order.
    outputTxt = "Appears in this episode:"
    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.
    table.sort( a )  -- Sort the names in alphabetical order (by first name)
    for _, n in ipairs( a ) do
        outputTxt = outputTxt .. "<br />&nbsp;&nbsp;[[".. n .. "]]"
    -- List the characters who were mentioned only, in alphabetical order.
    a = {}  -- Clear the array so we can use it again.
    for i, _ in pairs( characterdat ) do  -- Populate the array.
        for _, g in pairs( characterdat[i].references ) do
            if g == tonumber( LinkNumber ) then
                table.insert( a, i )
    if next(a) ~= nil then -- Only output "mentioned" if it's not empty.
        outputTxt = outputTxt .. "<br /><br />Mentioned or referenced only:"
        table.sort( a )
        for _, n in ipairs( a ) do
            outputTxt = outputTxt .. "<br />&nbsp;&nbsp;[[".. n .. "]]"
    return outputTxt
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.