FANDOM


local p = {}
 
function trim( str )
    if (not(str) or #str == 0) then
        return ""
    end
    return mw.text.trim(str)
end
 
function replace( str, chr)
    local sarr = mw.text.split(str,'')
    local result = ""
    for i = 1, #sarr do
        if chr[sarr[i]] then
            result = result .. chr[sarr[i]]
        else 
            result = result .. sarr[i]
        end
    end
    return result
end
 
function max( a, b)
    if a > b then
        return a
    else
        return b
    end
end
 
 
function p.usernameParser( frame )
    local names = {}
    local namesi = 1
    local result = ""
    local usernames = mw.text.split(frame.args[1], ",", true)
    local displaynames = mw.text.split(frame.args[2], ",", true)
    for i = 1, max(#usernames, #displaynames) do
        if i > #usernames or trim(usernames[i]) == "" then
            if not(trim(displaynames[i]) == "") then
                names[namesi] = displaynames[i]
                namesi = namesi + 1
            end
        elseif i > #displaynames or trim(displaynames[i]) == "" then
            names[namesi] = "[[User:" .. trim(usernames[i]) .. "|" .. trim(usernames[i]) .. "]]"
            namesi = namesi + 1
        else
            names[namesi] = "[[User:" .. trim(usernames[i]) .. "|" .. trim(displaynames[i]) .. "]]"
            namesi = namesi + 1
        end
    end
 
 
 
    if #names == 0 then
        return "the community"
    elseif #names == 1 then
        return trim(names[1])
    end
 
    result = trim(names[1])
    for i = 2, #names-1 do
        result = result .. trim(frame.args[3]) .. " " .. trim(names[i])
    end
    result = result .. " " .. trim(frame.args[4]) .. " " .. trim(names[#names])
    return result
end
 
function p.getServer( frame )
    local result = ""
    local vers = { I=true, II=true, III=true, IV=true, V=true, VI=true, VII=true, VIII=true, IX = true, X = true }
    local other = {}
    local checkInfoBox = { town = "TownInfo", event = "EventInfo", location = "LocationInfo"}
    local q = mw.text.split( mw.title.getCurrentTitle().text, ' ')
    local txt = mw.title.getCurrentTitle():getContent()
    local chk = 0
    local debla = {}
    debla["("] = ""
    debla[")"] = ""
    for i = 1, #q - 1 do
        if(replace(mw.ustring.lower( q[i] ),debla) == "public" and replace(mw.ustring.lower( q[i+1] ), debla) == "server") then
            chk = 1
        end
    end
    if chk == 0 then
        return "[[Category:Invalid Public Server Page]]"
    end
    local x = mw.text.split( mw.title.getCurrentTitle().text, '[()]')
    local y = {}
    if #x <= 1 then
        y = mw.text.split( x[1], ' ')
    else 
        y = mw.text.split( x[2], ' ')
    end
    for i = 1, #y do
        if vers[y[i]] then
            result = result .. "[[Category:Public Server " .. y[i] .. "]]"
        elseif other[y[i]] then
            result = result .. "[[Category:" .. other[y[i]] .. "]]"
        end
        if checkInfoBox[mw.ustring.lower(y[i])] then
            if #mw.text.split(txt, "{{" .. checkInfoBox[mw.ustring.lower(y[i])]) < 2 then
                result = result .. "[[Category:Missing " .. checkInfoBox[mw.ustring.lower(y[i])] .. "]]"
            end
        end
    end
    return result
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.