Fandom

Parks and Recreation Wiki

Module:Appearance

578pages on
this wiki
Add New Page
Talk0

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.

local p = {}
local data = mw.loadData('Module:Appearance/data')
 
function p.tab(frame)
    local args = frame.args
    local season = args[1]
    local episodes = args[2]
    episodes = mw.text.split(episodes, ',')
    local tr = '!#\n!Name\n'
    local cols = 1
    if #episodes > 10 then
        tr = tr .. tr
        cols = 2
    end
    if #episodes > 15 then
        tr = tr .. '!#\n!Name\n'
        cols = 3
    end
    local tab = '{|class="appearances-table cols-' .. cols .. '"\n'
    tab = tab .. tr .. '|-\n'
    for i = 1, #episodes do
        local number = episodes[i]
        if season == "6" then
            if i == 1 then
                number = "1/2"
            else if i > 1 then
                number = tonumber(episodes[i]) + 1
            end
            end
            if i == 20 then
                number = "21/22"
            end
        end
        if season == "7" then
            if i == 12 then
                number = "12/13"
            end
        end
        local str = mw.text.split(data[season][tonumber(episodes[i])], '%(')[1]
        if string.sub(str, #str, #str) == ' ' then
            str = string.sub(str, 1, #str - 1)
        end
        local tri = '|' .. number .. '.\n|"[[' .. data[season][tonumber(episodes[i])] .. '|' .. str .. ']]"\n'
        if cols == 2 then
            if i % 2 == 0 then
                tri = tri .. '|-\n'
            end
        else if cols == 3 then
            if i % 3 == 0 then
                tri = tri .. '|-\n'
            end
        else
            tri = tri .. '|-\n'
        end
        end
        tab = tab .. tri
    end
    tab = tab .. '|}'
    return '=== Season ' .. season .. ' ===\n' .. tab
end
 
return p

Also on Fandom

Random Wiki