Mudanças entre as edições de "Módulo:Teste"
Ir para navegação
Ir para pesquisar
m |
m |
||
| Linha 16: | Linha 16: | ||
local bauImg = bau == 'ouro' and 'Chest_gold.png' or 'Chest_normal.png' | local bauImg = bau == 'ouro' and 'Chest_gold.png' or 'Chest_normal.png' | ||
local imgHtml | local imgHtml = frame:preprocess('[[File:' .. img .. '|150px|link=]]') | ||
local bauHtml | local bauHtml = frame:preprocess('[[File:' .. bauImg .. '|link=]]') | ||
local href | local href = tostring(mw.uri.localUrl(link)) | ||
local card = | local card = mw.html.create('a') | ||
card:attr('class', 'island-card') | |||
:attr('href', href) | |||
' | |||
cards[#cards+1] = card | card:tag('span'):attr('class', 'island-img') | ||
:node(mw.html.create(''):wikitext(imgHtml)) | |||
card:tag('span'):attr('class', 'island-name') | |||
:wikitext(nome) | |||
card:tag('span'):attr('class', 'island-chests') | |||
:node(mw.html.create(''):wikitext(qtd .. ' ' .. bauHtml)) | |||
cards[#cards+1] = tostring(card) | |||
i = i + 1 | i = i + 1 | ||
end | end | ||
local grid = mw.html.create('div') | |||
grid:attr('class', 'island-grid') | |||
:node(mw.html.create(''):wikitext(table.concat(cards))) | |||
return tostring(grid) | |||
end | end | ||
return p | return p | ||
Edição das 22h25min 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 imgHtml = frame:preprocess('[[File:' .. img .. '|150px|link=]]')
local bauHtml = frame:preprocess('[[File:' .. bauImg .. '|link=]]')
local href = tostring(mw.uri.localUrl(link))
local card = mw.html.create('a')
card:attr('class', 'island-card')
:attr('href', href)
card:tag('span'):attr('class', 'island-img')
:node(mw.html.create(''):wikitext(imgHtml))
card:tag('span'):attr('class', 'island-name')
:wikitext(nome)
card:tag('span'):attr('class', 'island-chests')
:node(mw.html.create(''):wikitext(qtd .. ' ' .. bauHtml))
cards[#cards+1] = tostring(card)
i = i + 1
end
local grid = mw.html.create('div')
grid:attr('class', 'island-grid')
:node(mw.html.create(''):wikitext(table.concat(cards)))
return tostring(grid)
end
return p