Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Module:ESColor

From Teriock
Revision as of 08:52, 23 April 2025 by Gpe (talk | contribs) (// via Wikitext Extension for VSCode)

Documentation for this module may be created at Module:ESColor/doc

local p = {}

function p.c ( frame )
    local life = tonumber(frame.args['life'])
    local storm = tonumber(frame.args['storm'])
    local necro = tonumber(frame.args['necro'])
    local flame = tonumber(frame.args['flame'])
    local nature = tonumber(frame.args['nature'])
    life_color = 'es-life'
    storm_color = 'es-storm'
    necro_color = 'es-necro'
    flame_color = 'es-flame'
    nature_color = 'es-nature'
    multi_color = 'es-multi'
    local color_counter = life + storm + necro + flame + nature
    if color_counter ~= 1 then
        return multi_color
    end
    if life == 1 then
        return life_color
    elseif storm == 1 then
        return storm_color
    elseif necro == 1 then
        return necro_color
    elseif flame == 1 then
        return flame_color
    elseif nature == 1 then
        return nature_color
    end
    return multi_color
end

function p.t ( frame )
    local life = tonumber(frame.args['life'])
    local storm = tonumber(frame.args['storm'])
    local necro = tonumber(frame.args['necro'])
    local flame = tonumber(frame.args['flame'])
    local nature = tonumber(frame.args['nature'])
    local elementsList = {}
    if life == 1 then
        table.insert(elementsList, 'Life')
    end
    if storm == 1 then
        table.insert(elementsList, 'Storm')
    end
    if necro == 1 then
        table.insert(elementsList, 'Necromancy')
    end
    if flame == 1 then
        table.insert(elementsList, 'Flame')
    end
    if nature == 1 then
        table.insert(elementsList, 'Nature')
    end
    if #elementsList == 0 then
        table.insert(elementsList, 'Celestial')
    end
    if #elementsList > 1 then
        elementsList[#elementsList] = 'and ' .. elementsList[#elementsList]
    end
    if #elementsList > 2 then
        return table.concat(elementsList, ', ')
    else
        return table.concat(elementsList, ' ')
    end
end

return p