Jump to content

Module:CharacterInfobox: Difference between revisions

From Elite Dangerous Wiki
Content deleted Content added
mNo edit summary
m Added Ethos images
 
(6 intermediate revisions by the same user not shown)
Line 13: Line 13:
output = ''
output = ''
if not HF.isempty(field.Value) then
if not HF.isempty(field.Value) then
if field.Value == "Independent" then
if field.Value == "Alliance" then
output = '[[File:Alliance_vector.svg|27px|link=]] ' .. '[[' .. field.Value .. ']]'
elseif field.Value == "Empire" then
output = '[[File:Empire_vector.svg|27px|link=]] ' .. '[[' .. field.Value .. ']]'
elseif field.Value == "Federation" then
output = '[[File:Federation_vector.svg|27px|link=]] ' .. '[[' .. field.Value .. ']]'
elseif field.Value == "Independent" then
output = field.Value
output = field.Value
else
output = '[[' .. field.Value .. ']]'
end
return output
end
end

function Infobox.Ethos( field, vars )
output = ''
if not HF.isempty(field.Value) then
if field.Value == "Combat" then
output = '[[File:Ethos Combat.svg|27px|link=]] ' .. field.Value
elseif field.Value == "Covert" then
output = '[[File:Ethos Covert.svg|27px|link=]] ' .. field.Value
elseif field.Value == "Finance" then
output = '[[File:Ethos Finance.svg|27px|link=]] ' .. field.Value
elseif field.Value == "Social" then
output = '[[File:Ethos Social.svg|27px|link=]] ' .. field.Value
else
else
output = '[[' .. field.Value .. ']]'
output = '[[' .. field.Value .. ']]'
Line 52: Line 76:
output = field.Value
output = field.Value
if not HF.isempty(field.PowerIcon) then
if not HF.isempty(field.PowerIcon) then
output = '[[File:' .. field.PowerIcon .. '|19px|link=]] ' .. output
output = '[[File:' .. field.PowerIcon .. '|35px|link=]] ' .. output
end
end
return output
return output
Line 60: Line 84:
output = ''
output = ''
if not HF.isempty(field.Value) then
if not HF.isempty(field.Value) then
output = '[[File:' .. field.Value .. '|285px]]'
output = '[[File:' .. field.Value .. '|306px]]'
end
end
return output
return output

Latest revision as of 21:24, 9 June 2015

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

local Infobox = {}
local HF = require('Module:HF')

function Infobox.Link( field, vars )
    output = ''
    if not HF.isempty(field.Value) then
        output = '[[' .. field.Value .. ']]'
        return output
    end
end

function Infobox.Allegiance( field, vars )
    output = ''
    if not HF.isempty(field.Value) then
        if field.Value == "Alliance" then
            output = '[[File:Alliance_vector.svg|27px|link=]] ' .. '[[' .. field.Value .. ']]'
        elseif field.Value == "Empire" then
            output = '[[File:Empire_vector.svg|27px|link=]] ' .. '[[' .. field.Value .. ']]'
        elseif field.Value == "Federation" then
            output = '[[File:Federation_vector.svg|27px|link=]] ' .. '[[' .. field.Value .. ']]'
        elseif field.Value == "Independent" then
            output = field.Value
        else
            output = '[[' .. field.Value .. ']]'
        end
        return output
    end
end

function Infobox.Ethos( field, vars )
    output = ''
    if not HF.isempty(field.Value) then
        if field.Value == "Combat" then
            output = '[[File:Ethos Combat.svg|27px|link=]] ' .. field.Value
        elseif field.Value == "Covert" then
            output = '[[File:Ethos Covert.svg|27px|link=]] ' .. field.Value
        elseif field.Value == "Finance" then
            output = '[[File:Ethos Finance.svg|27px|link=]] ' .. field.Value
        elseif field.Value == "Social" then
            output = '[[File:Ethos Social.svg|27px|link=]] ' .. field.Value
        else
            output = '[[' .. field.Value .. ']]'
        end
        return output
    end
end

function Infobox.Quantify( field, vars )
    local unit = field.Unit or ''
    local value = field.Value or field.Default or '?'
    if HF.isempty(value) then 
        return '---'
    else
        return value .. ' ' .. unit
    end
end

function Infobox.Newline( field, vars )
    local output = ''
    if not HF.isempty(field.Value) then
        local ships = HF.explode(';', field.Value)
        table.sort(ships)
        for i, ship in ipairs(ships) do
            output = output .. HF.trim(ship) .. '<br />'
        end
 
        if string.sub(output, -6) == '<br />' then
            output = string.sub( output, 1, -7 )
        end
 
        return output
    end
end

function Infobox.PowerIcon( field, vars )
    output = field.Value
    if not HF.isempty(field.PowerIcon) then
        output = '[[File:' .. field.PowerIcon .. '|35px|link=]] ' .. output
    end
    return output
end

function Infobox.MainImage( field, vars )
    output = ''
    if not HF.isempty(field.Value) then
        output = '[[File:' .. field.Value .. '|306px]]'
    end
    return output
end

return Infobox