익명
×
새 문서 만들기
여기에 문서 제목을 쓰세요:
We currently have 962 articles on 루리위키. Type your article name above or click on one of the titles below and start writing!



962Articles

모듈:샤인 포스트 Be your Idol/캐릭터 메모리: 두 판 사이의 차이

편집 요약 없음
편집 요약 없음
12번째 줄: 12번째 줄:
             ['table-layout'] = 'fixed',
             ['table-layout'] = 'fixed',
             border = 'none',
             border = 'none',
             ['margin-bottom'] = '20px' -- 메모리 묶음 사이의 간격 추가
             ['margin-bottom'] = '20px'
         })
         })


     local i = 1
     local hasAnyData = false
    local hasRow = false


     while args['이름' .. i] or args['타입' .. i] do
     -- 1번부터 50번까지 중간에 빈 번호가 있어도 모두 검사합니다.
        hasRow = true
    for i = 1, 50 do
        -- 타입이나 이름 중 하나라도 존재할 때만 행을 만듭니다.
        if (args['타입' .. i] and args['타입' .. i] ~= '') or (args['이름' .. i] and args['이름' .. i] ~= '') then
            hasAnyData = true


        local m_type  = args['타입' .. i]  or ''
            local m_type  = args['타입' .. i]  or ''
        local m_name  = args['이름' .. i]  or ''
            local m_name  = args['이름' .. i]  or ''
        local m_guest  = args['게스트' .. i] or ''
            local m_guest  = args['게스트' .. i] or ''
        local m_stat  = args['스텟' .. i]  or ''
            local m_stat  = args['스텟' .. i]  or ''
        local m_detail = args['내용' .. i]  or ''
            local m_detail = args['내용' .. i]  or ''


        -- ① 요약 행 (타입 / 이름 / 게스트)
            -- ① 기본 정보 행 (타입 / 이름 / 게스트)
        local row = html:tag('tr')
            local row = html:tag('tr')
 
        row:tag('td')
            :css({
                ['background-color'] = '#3478bf',
                color = 'white',
                ['font-weight'] = 'bold',
                ['text-align'] = 'center',
                width = '20%',
                ['border-top'] = '2px solid #000',
                ['border-left'] = '2px solid #000'
            })
            :wikitext(m_type)
 
        if m_guest == '' then
             row:tag('td')
             row:tag('td')
                :attr('colspan', '2')
                 :css({
                 :css({
                    ['background-color'] = '#3478bf',
                    color = 'white',
                     ['font-weight'] = 'bold',
                     ['font-weight'] = 'bold',
                    ['text-align'] = 'center',
                    width = '20%',
                     ['border-top'] = '2px solid #000',
                     ['border-top'] = '2px solid #000',
                    ['border-left'] = '2px solid #000'
                })
                :wikitext(m_type)
            -- 게스트 유무에 따른 셀 통합 처리
            if m_guest == '' or m_guest == nil or m_guest:match("^%s*$") then
                row:tag('td')
                    :attr('colspan', '2')
                    :css({
                        ['font-weight'] = 'bold',
                        ['border-top'] = '2px solid #000',
                        ['border-right'] = '2px solid #000',
                        ['padding-left'] = '10px'
                    })
                    :wikitext(m_name)
            else
                row:tag('td')
                    :css({
                        ['font-weight'] = 'bold',
                        width = '55%',
                        ['border-top'] = '2px solid #000',
                        ['padding-left'] = '10px'
                    })
                    :wikitext(m_name)
                local guestCell = row:tag('td')
                    :css({
                        ['text-align'] = 'center',
                        width = '25%',
                        ['border-top'] = '2px solid #000',
                        ['border-right'] = '2px solid #000'
                    })
                guestCell:tag('span'):css({ color = '#666', ['font-size'] = '0.9em' }):wikitext('with ')
                guestCell:wikitext(m_guest)
            end
            -- ② 추가 스텟 행
            html:tag('tr')
                :tag('td')
                :attr('colspan', '3')
                :css({
                    ['background-color'] = '#f0f4f9',
                    ['border-left'] = '2px solid #000',
                     ['border-right'] = '2px solid #000',
                     ['border-right'] = '2px solid #000',
                     ['padding-left'] = '10px'
                     ['padding'] = '6px 12px',
                    ['font-size'] = '0.9em'
                 })
                 })
                 :wikitext(m_name)
                 :wikitext("'''추가 스탯:''' " .. (m_stat ~= '' and m_stat or '없음'))
        else
 
             row:tag('td')
             -- ③ 상세 내용 행 (접기 기능)
            local detailRow = html:tag('tr')
            local detailCell = detailRow:tag('td')
                :attr('colspan', '3')
                 :css({
                 :css({
                     ['font-weight'] = 'bold',
                     padding = '0',
                     width = '55%',
                     ['border-left'] = '2px solid #000',
                     ['border-top'] = '2px solid #000',
                     ['border-right'] = '2px solid #000',
                     ['padding-left'] = '10px'
                     ['border-bottom'] = '2px solid #000'
                 })
                 })
                :wikitext(m_name)


             local guestCell = row:tag('td')
             local collapse = detailCell:tag('div')
                :addClass('mw-collapsible mw-collapsed')
                :css({ width = '100%' })
 
            collapse:tag('div')
                :addClass('mw-collapsible-toggle')
                 :css({
                 :css({
                    ['float'] = 'none',
                     ['text-align'] = 'center',
                     ['text-align'] = 'center',
                     width = '25%',
                     background = '#eee',
                     ['border-top'] = '2px solid #000',
                    ['font-size'] = '0.85em',
                     ['border-right'] = '2px solid #000'
                    ['padding'] = '4px',
                     ['border-top'] = '1px solid #ccc',
                     ['cursor'] = 'pointer'
                })
                :wikitext("'''▼ 상세 내용 보기 / 닫기 ▼'''")
 
            collapse:tag('div')
                :addClass('mw-collapsible-content')
                :css({
                    padding = '12px',
                    background = '#fff'
                 })
                 })
            guestCell:tag('span'):css({ color = '#666', ['font-size'] = '0.9em' }):wikitext('with ')
                :wikitext((m_detail ~= '' and m_detail ~= '-') and m_detail or '상세 내용이 없습니다.')
            guestCell:wikitext(m_guest)
         end
         end
    end


        -- ② 추가 스텟 행
    if not hasAnyData then
         html:tag('tr')
         return '<div style="color:red; font-weight:bold;">데이터가 입력되지 않았거나 호출 방식에 오류가 있습니다.</div>'
            :tag('td')
            :attr('colspan', '3')
            :css({
                ['background-color'] = '#f0f4f9',
                ['border-left'] = '2px solid #000',
                ['border-right'] = '2px solid #000',
                ['padding'] = '6px 12px',
                ['font-size'] = '0.9em'
            })
            :wikitext("'''추가 스탯:''' " .. (m_stat ~= '' and m_stat or '없음'))
 
        -- ③ 상세 내용 (개선된 접기 구조)
        local detailRow = html:tag('tr')
        local detailCell = detailRow:tag('td')
            :attr('colspan', '3')
            :css({
                padding = '0',
                ['border-left'] = '2px solid #000',
                ['border-right'] = '2px solid #000',
                ['border-bottom'] = '2px solid #000'
            })
 
        -- 접기 블록 (mw-collapsible-toggle 위치 조정)
        local collapse = detailCell:tag('div')
            :addClass('mw-collapsible mw-collapsed')
            :css({ width = '100%' })
 
        -- 사용자가 클릭할 영역 (헤더)
        collapse:tag('div')
            :addClass('mw-collapsible-toggle') -- 이 클래스가 있어야 제목을 눌러도 접힙니다
            :css({
                ['float'] = 'none',
                ['text-align'] = 'center',
                background = '#eee',
                ['font-size'] = '0.85em',
                ['padding'] = '4px',
                ['border-top'] = '1px solid #ccc',
                ['cursor'] = 'pointer'
            })
            :wikitext("'''▼ 상세 내용 보기 / 닫기 ▼'''")
 
        -- 실제 내용
        collapse:tag('div')
            :addClass('mw-collapsible-content')
            :css({
                padding = '12px',
                background = '#fff',
                ['line-height'] = '1.6'
            })
            :wikitext(m_detail ~= '' and m_detail or '상세 내용이 없습니다.')
 
        i = i + 1
     end
     end
    if not hasRow then return '' end


     return tostring(html)
     return tostring(html)

2026년 1월 26일 (월) 09:39 판

데이터가 입력되지 않았거나 호출 방식에 오류가 있습니다.

사용 예시

숫자를 늘리면 무한히 늘어납니다

{{#invoke:샤인 포스트 Be your Idol/캐릭터 메모리|render
|타입1 = 
|이름1 = 
|게스트1 =
|내용1 = 

|타입2 = 
|이름2 = 
|게스트2 = 
|내용2 = 
}}

local p = {}

function p.render(frame)
    local parent = frame:getParent()
    local args = parent and parent.args or frame.args

    local html = mw.html.create('table')
        :addClass('wikitable')
        :css({
            width = '100%',
            ['border-collapse'] = 'collapse',
            ['table-layout'] = 'fixed',
            border = 'none',
            ['margin-bottom'] = '20px'
        })

    local hasAnyData = false

    -- 1번부터 50번까지 중간에 빈 번호가 있어도 모두 검사합니다.
    for i = 1, 50 do
        -- 타입이나 이름 중 하나라도 존재할 때만 행을 만듭니다.
        if (args['타입' .. i] and args['타입' .. i] ~= '') or (args['이름' .. i] and args['이름' .. i] ~= '') then
            hasAnyData = true

            local m_type   = args['타입' .. i]   or ''
            local m_name   = args['이름' .. i]   or ''
            local m_guest  = args['게스트' .. i] or ''
            local m_stat   = args['스텟' .. i]   or ''
            local m_detail = args['내용' .. i]   or ''

            -- ① 기본 정보 행 (타입 / 이름 / 게스트)
            local row = html:tag('tr')
            row:tag('td')
                :css({
                    ['background-color'] = '#3478bf',
                    color = 'white',
                    ['font-weight'] = 'bold',
                    ['text-align'] = 'center',
                    width = '20%',
                    ['border-top'] = '2px solid #000',
                    ['border-left'] = '2px solid #000'
                })
                :wikitext(m_type)

            -- 게스트 유무에 따른 셀 통합 처리
            if m_guest == '' or m_guest == nil or m_guest:match("^%s*$") then
                row:tag('td')
                    :attr('colspan', '2')
                    :css({
                        ['font-weight'] = 'bold',
                        ['border-top'] = '2px solid #000',
                        ['border-right'] = '2px solid #000',
                        ['padding-left'] = '10px'
                    })
                    :wikitext(m_name)
            else
                row:tag('td')
                    :css({
                        ['font-weight'] = 'bold',
                        width = '55%',
                        ['border-top'] = '2px solid #000',
                        ['padding-left'] = '10px'
                    })
                    :wikitext(m_name)

                local guestCell = row:tag('td')
                    :css({
                        ['text-align'] = 'center',
                        width = '25%',
                        ['border-top'] = '2px solid #000',
                        ['border-right'] = '2px solid #000'
                    })
                guestCell:tag('span'):css({ color = '#666', ['font-size'] = '0.9em' }):wikitext('with ')
                guestCell:wikitext(m_guest)
            end

            -- ② 추가 스텟 행
            html:tag('tr')
                :tag('td')
                :attr('colspan', '3')
                :css({
                    ['background-color'] = '#f0f4f9',
                    ['border-left'] = '2px solid #000',
                    ['border-right'] = '2px solid #000',
                    ['padding'] = '6px 12px',
                    ['font-size'] = '0.9em'
                })
                :wikitext("'''추가 스탯:''' " .. (m_stat ~= '' and m_stat or '없음'))

            -- ③ 상세 내용 행 (접기 기능)
            local detailRow = html:tag('tr')
            local detailCell = detailRow:tag('td')
                :attr('colspan', '3')
                :css({
                    padding = '0',
                    ['border-left'] = '2px solid #000',
                    ['border-right'] = '2px solid #000',
                    ['border-bottom'] = '2px solid #000'
                })

            local collapse = detailCell:tag('div')
                :addClass('mw-collapsible mw-collapsed')
                :css({ width = '100%' })

            collapse:tag('div')
                :addClass('mw-collapsible-toggle')
                :css({
                    ['float'] = 'none',
                    ['text-align'] = 'center',
                    background = '#eee',
                    ['font-size'] = '0.85em',
                    ['padding'] = '4px',
                    ['border-top'] = '1px solid #ccc',
                    ['cursor'] = 'pointer'
                })
                :wikitext("'''▼ 상세 내용 보기 / 닫기 ▼'''")

            collapse:tag('div')
                :addClass('mw-collapsible-content')
                :css({
                    padding = '12px',
                    background = '#fff'
                })
                :wikitext((m_detail ~= '' and m_detail ~= '-') and m_detail or '상세 내용이 없습니다.')
        end
    end

    if not hasAnyData then
        return '<div style="color:red; font-weight:bold;">데이터가 입력되지 않았거나 호출 방식에 오류가 있습니다.</div>'
    end

    return tostring(html)
end

return p