Módulo:PetOutfitsVisualizer: mudanças entre as edições

De TibiaRPGBrasil Wiki
Ir para navegação Ir para pesquisar
Sem resumo de edição
Sem resumo de edição
Linha 1: Linha 1:
local p = {}
local p = {}


function explode(str, sep)
function p.render(frame)
local i, pos, tmp, t = 0, 1, "", {}
    local outfitsStr = frame.args.outfits or ""
for s, e in function() return string.find(str, sep, pos) end do
    local html = '<div class="pet-outfit-gallery" style="display:flex; flex-wrap:wrap; gap:5px;">'
tmp = str:sub(pos, s - 1)
        tmp = tmp:gsub("^%s*(.-)%s*$", "%1") -- trim
table.insert(t, tmp)
pos = e + 1


i = i + 1
    for outfitPair in outfitsStr:gmatch("[^;]+") do
end
        local file, caption = outfitPair:match("^%s*(.-)%s*,%s*(.-)%s*$")
        if file then
            html = html .. string.format(
                '<div style="text-align:center;"><img src="/wiki/Special:FilePath/%s" style="height:72px;"><br>%s</div>',
                file, caption or file
            )
        end
    end


tmp = str:sub(pos)
     html = html .. '</div>'
     tmp = tmp:gsub("^%s*(.-)%s*$", "%1") -- trim
    return html
table.insert(t, tmp)
return t
end
end
function p.render(frame)
    local outfits = explode(frame.args.outfits,";")
    local retStr = ""
    for i,outfit in pairs(outfits) do
      retStr = retStr .. "File:" .. outfit .. "\n"
    end
    return "File:Thanatos Level 1.gif|Level 1"
end
return p

Edição das 19h05min de 16 de agosto de 2025

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

local p = {}

function p.render(frame)
    local outfitsStr = frame.args.outfits or ""
    local html = '<div class="pet-outfit-gallery" style="display:flex; flex-wrap:wrap; gap:5px;">'

    for outfitPair in outfitsStr:gmatch("[^;]+") do
        local file, caption = outfitPair:match("^%s*(.-)%s*,%s*(.-)%s*$")
        if file then
            html = html .. string.format(
                '<div style="text-align:center;"><img src="/wiki/Special:FilePath/%s" style="height:72px;"><br>%s</div>',
                file, caption or file
            )
        end
    end

    html = html .. '</div>'
    return html
end