Mudanças entre as edições de "Módulo:Teste"

De Wiki Gla
Ir para navegação Ir para pesquisar
m
m
Linha 1: Linha 1:
local p = {}
local p = {}
local BAU_COMUM = 'https://i.imgur.com/URL_COMUM'
local BAU_OURO  = 'https://i.imgur.com/URL_OURO'


function p.main(frame)
function p.main(frame)
     local args = frame:getParent().args
     local args = frame:getParent().args
     local cards = {}
     local cards = {}


Linha 14: Linha 10:
         if not nome or mw.text.trim(nome) == '' then break end
         if not nome or mw.text.trim(nome) == '' then break end


         local link = args['link' .. i] or ''
         local link = mw.text.trim(args['link' .. i] or '')
         local img  = args['img'  .. i] or ''
         local img  = mw.text.trim(args['img'  .. i] or '')
         local qtd  = args['qtd'  .. i] or '0'
         local qtd  = mw.text.trim(args['qtd'  .. i] or '0')
         local bau  = mw.text.trim(args['bau' .. i] or 'comum')
         local bau  = mw.text.trim(args['bau' .. i] or 'comum')
 
         local bauImg = bau == 'ouro' and 'Chest_gold.png' or 'Chest_normal.png'
         local bauSrc = bau == 'ouro' and BAU_OURO or BAU_COMUM
 
        local imgFile = mw.getCurrentFrame():callParserFunction(
            '#tag', 'span',
            frame:preprocess('[[File:' .. img .. '|150px|link=' .. link .. ']]')
        )
 
        local card = mw.html.create('a')
            :addClass('island-card')
            :attr('href', tostring(mw.uri.localUrl(link)))
 
        card:tag('span')
            :addClass('island-img')
            :wikitext('[[File:' .. img .. '|150px|link=]]')
 
        card:tag('span')
            :addClass('island-name')
            :wikitext(link ~= '' and '[[' .. link .. '|' .. nome .. ']]' or nome)


         card:tag('span')
         local parts = {}
            :addClass('island-chests')
        parts[#parts+1] = '|nome='   .. nome
            :wikitext(qtd .. ' [[File:' .. (bau == 'ouro' and 'Chest_gold.png' or 'Chest_normal.png') .. '|link=]]')
        parts[#parts+1] = '|link='   .. link
        parts[#parts+1] = '|img='   .. img
        parts[#parts+1] = '|qtd='   .. qtd
        parts[#parts+1] = '|bauimg=' .. bauImg


         cards[#cards + 1] = tostring(card)
         cards[#cards+1] = frame:preprocess('{{#widget:TesteCard' .. table.concat(parts) .. '}}')
         i = i + 1
         i = i + 1
     end
     end


     local grid = mw.html.create('div')
     return '<div class="island-grid">' .. table.concat(cards) .. '</div>'
        :addClass('island-grid')
        :wikitext(table.concat(cards))
 
    return tostring(grid)
end
end


return p
return p

Edição das 22h21min de 12 de março de 2026

A documentação para este módulo pode ser criada em Módulo:Teste/doc

local p = {}

function p.main(frame)
    local args = frame:getParent().args
    local cards = {}

    local i = 1
    while true do
        local nome = args['nome' .. i]
        if not nome or mw.text.trim(nome) == '' then break end

        local link = mw.text.trim(args['link' .. i] or '')
        local img  = mw.text.trim(args['img'  .. i] or '')
        local qtd  = mw.text.trim(args['qtd'  .. i] or '0')
        local bau  = mw.text.trim(args['bau'  .. i] or 'comum')
        local bauImg = bau == 'ouro' and 'Chest_gold.png' or 'Chest_normal.png'

        local parts = {}
        parts[#parts+1] = '|nome='   .. nome
        parts[#parts+1] = '|link='   .. link
        parts[#parts+1] = '|img='    .. img
        parts[#parts+1] = '|qtd='    .. qtd
        parts[#parts+1] = '|bauimg=' .. bauImg

        cards[#cards+1] = frame:preprocess('{{#widget:TesteCard' .. table.concat(parts) .. '}}')
        i = i + 1
    end

    return '<div class="island-grid">' .. table.concat(cards) .. '</div>'
end

return p