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

Module:S2TechniqueTable: Difference between revisions

From Gensopedia
mNo edit summary
mNo edit summary
 
Line 6: Line 6:
         :addClass('table')
         :addClass('table')
         :css('border', '1px solid #0077c0')
         :css('border', '1px solid #0077c0')
 
       
    -- Add identifying class for CSS
    tbl:addClass('attacktable-responsive')
   
     -- Header row
     -- Header row
     local headerRow = tbl:tag('tr')
     local headerRow = tbl:tag('tr')

Latest revision as of 16:54, 10 December 2025

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

local p = {}

function p.render(frame)
    -- Create outer table
    local tbl = mw.html.create('table')
        :addClass('table')
        :css('border', '1px solid #0077c0')
        
    -- Add identifying class for CSS
    tbl:addClass('attacktable-responsive')
    
    -- Header row
    local headerRow = tbl:tag('tr')
    local headers = {
        { text = 'Name',    width = '15%', border = 'border-top-left-radius:0;' },
        { text = 'Type',    width = '10%' },
        { text = 'Element', width = '15%' },
        { text = 'Range',   width = '10%' },
        { text = 'Target',  width = '15%' },
        { text = 'Effect',  width = '30%', border = 'border-top-right-radius:0;' }
    }

    for _, h in ipairs(headers) do
        headerRow:tag('th')
            :addClass('header')
            :cssText(h.border or '')
            :css('width', h.width)
            :css('text-align', 'center')
            :wikitext(h.text)
            :done()
    end

    -- Collect rows
    for i = 1, 4 do
        local type = frame.args['type_' .. i]
        if type and type ~= '' then
            local r = tbl:tag('tr')
            r:tag('td'):wikitext(attack or 'Attack ' .. i)
            r:tag('td'):wikitext(frame.args['type_' .. i] or 'Physical')
            r:tag('td'):wikitext(frame.args['element_' .. i] or '—')
            r:tag('td'):wikitext(frame.args['range_' .. i] or 'M')
            r:tag('td'):wikitext(frame.args['target_' .. i] or 'Single')
            r:tag('td'):wikitext(frame.args['effect_' .. i] or '—')
        end
    end

    return tostring(tbl)
end

return p