Module:ElementInfobox

From MB Wiki
Revision as of 07:14, 24 December 2025 by Ais (talk | contribs) (Created page with "local p = {} -- Color mapping local colors = { Fire = '#cc3333', Water = '#3366cc', Wind = '#33cccc', Earth = '#996633', Lightning = '#ffcc00', Ice = '#66ccff', Wood = '#339933', Grass = '#88cc44' } function p.infobox(frame) local args = frame.args local name = args.name or 'Unknown' -- Get color or default local color = colors[name] or '#666666' -- Build the infobox local output = {''} table.in...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

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

local p = {}

-- Color mapping
local colors = {
    Fire = '#cc3333',
    Water = '#3366cc',
    Wind = '#33cccc',
    Earth = '#996633',
    Lightning = '#ffcc00',
    Ice = '#66ccff',
    Wood = '#339933',
    Grass = '#88cc44'
}

function p.infobox(frame)
    local args = frame.args
    local name = args.name or 'Unknown'
    
    -- Get color or default
    local color = colors[name] or '#666666'
    
    -- Build the infobox
    local output = {''}
    
    table.insert(output, '{| class="wikitable" style="width:300px; float:right; margin-left:15px;"')
    table.insert(output, '|+ style="font-size:larger;" | ' .. name .. ' Element')
    table.insert(output, '|-')
    table.insert(output, '! colspan="2" style="background:' .. color .. '; color:white; text-align:center;" | ' .. name)
    table.insert(output, '|-')
    
    -- Image
    if args.image then
        table.insert(output, '| colspan="2" style="text-align:center;" | [[File:' .. args.image .. '|200px]]')
    else
        table.insert(output, '| colspan="2" style="text-align:center;" | <i>No image yet</i>')
    end
    
    -- Fields
    local fields = {
        {'Description', args.description},
        {'Offensive Spell', args.offensive},
        {'Defensive Spell', args.defensive},
        {'Curative Spell', args.curative},
        {'Enhancement Spell', args.enhancement},
        {'Behavior Traits', args.behavior or 'See below'}
    }
    
    for _, field in ipairs(fields) do
        local label, value = field[1], field[2]
        table.insert(output, '|-')
        table.insert(output, '! ' .. label)
        table.insert(output, '| ' .. (value or 'Unknown'))
    end
    
    table.insert(output, '|}')
    
    return table.concat(output, '\n')
end

return p