FANDOM


-- <nowiki>
local p = {}
 
local tables = require('Module:Tables')
 
function makecell(name, color, textcolor, width)
    return {text = name, attr = {colspan = width}, css = {['color'] = textcolor, ['background-color'] = color, ['text-align'] = 'center'}}
end
 
function p.maketable(frame)
    local args = frame:getParent().args
    local series = args.series
    local hidechatheads = args.hidechatheads
    local questcount = 0
    local colors = {feat = "#98e553", ref = "#f6ab58", ['not'] = "lightgrey"}
    local textcolors = {feat = '#245200', ref = '#582e00', ['not'] = 'black'}
    local names = {feat = "F", ref = "''R''", ['not'] = ""}
    local characters = {{{text = 'Character', tag = 'th', attr = {rowspan = 2}, css = {['font-size'] = '18px'}}}, {false}}
    for i=1,100 do
        if args['questname'..i] then
            questcount = questcount + 1
                local name = args['questname'..i]
                local icon = args['questicon'..i] == 'default' and 'Quest Icon Crest' or name..' icon'
                local abbr = name
                if args['questabbr'..i] ~= '' then
                   abbr = args['questabbr'..i] 
                end
                local template = frame:expandTemplate{title = 'QuestIcon', args = {name, pic = icon, txt = abbr, newline = 'yes'}}
                characters[2][i+1] = {text = template, tag = 'th'}
        else
            break
        end
    end
    characters[1][2] = {text = series and '[['..series..'|'..'Quests]]' or 'Quests', tag = 'th', attr = {colspan = questcount}, css = {['font-size'] = '17px'}}
    for i=1,1000 do
        if args['charname'..i] then
            local name = args['charname'..i]
            local chathead = args['charhead'..i]
            local alt = args['charalt'..i] or name
            local nameandalt = '[['..name..']]'
 
            if args['charalt'..i] ~= '' then
                nameandalt = '[['..name..'|'..alt..']]'
            end
 
            if hidechatheads ~= "yes" and args['charhead'..i] ~= 'not' then
                nameandalt = frame:expandTemplate{title = 'chatl', args = {name, pic = chathead, txt = alt}}
            end
 
            characters[i+2] = {}
                characters[i+2][1] = {text = nameandalt}
            local unique = 1
            for j=1,questcount do
                local arg = args['char'..i..'quest'..j]
                local color = colors[arg]
                local txtcolor = textcolors[arg]
                local name = names[arg]
                if j > 1 and arg == args['char'..i..'quest'..(j-1)] then
                    characters[i+2][unique+1] = makecell(name, color, txtcolor, characters[i+2][unique+1].attr.colspan + 1)
                    characters[i+2][j+1] = false
                else
 
                    characters[i+2][j+1] = makecell(name, color, txtcolor, 1)
                    unique = j
                end
            end
        else
            break
        end
    end
    footer = tostring(mw.html.create( 'span' ):wikitext( "''Green with the letter \"F\" denotes a character featuring in that quest.''" ):css({color = 'green'}):done())
    footer = footer..'<br />'
    footer = footer..tostring(mw.html.create( 'span' ):wikitext( "''Orange with an italicised \"R\" denotes they are only referenced.''" ):css({color = 'orange'}):done())
    table.insert(characters, {{text = footer, tag = 'th', attr = {colspan = questcount + 1}}})
    local charactertable = mw.html.create('table'):addClass('wikitable')
    tables._table(charactertable, characters)
    return tostring(charactertable)
end
return p

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.