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
Created page with "local p = {} function p.render(frame) -- Create outer table local tbl = mw.html.create('table') :addClass('table') :css('border', '1px solid #0077c0') -- Header row local headerRow = tbl:tag('tr') local headers = { { text = 'Name', width = '25%', border = 'border-top-left-radius:0;' }, { text = 'Type', width = '10%' }, { text = 'Element', width = '10%' }, { text = 'Range', width = '10%' },..."
 
mNo edit summary
Line 10: Line 10:
     local headerRow = tbl:tag('tr')
     local headerRow = tbl:tag('tr')
     local headers = {
     local headers = {
         { text = 'Name',    width = '25%', border = 'border-top-left-radius:0;' },
         { text = 'Name',    width = '15%', border = 'border-top-left-radius:0;' },
         { text = 'Type',    width = '10%' },
         { text = 'Type',    width = '10%' },
         { text = 'Element', width = '10%' },
         { text = 'Element', width = '10%' },
         { text = 'Range',  width = '10%' },
         { text = 'Range',  width = '10%' },
         { text = 'Target',  width = '10%' },
         { text = 'Target',  width = '10%' },
         { text = 'Effect',  width = '35%', border = 'border-top-right-radius:0;' }
         { text = 'Effect',  width = '25%', border = 'border-top-right-radius:0;' }
     }
     }


Line 29: Line 29:


     -- Collect rows
     -- Collect rows
     for i = 1, 7 do
     for i = 1, 4 do
         local attack = frame.args['attack_' .. i]
         local type = frame.args['type_' .. i]
         if attack and attack ~= '' then
         if type and type ~= '' then
             local r = tbl:tag('tr')
             local r = tbl:tag('tr')
             r:tag('td'):wikitext(attack or 'Attack ' .. i)
             r:tag('td'):wikitext(attack or 'Attack ' .. i)

Revision as of 15:22, 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')

    -- 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 = '10%' },
        { text = 'Range',   width = '10%' },
        { text = 'Target',  width = '10%' },
        { text = 'Effect',  width = '25%', 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