Jump to content

📢 Please make sure to read our Style Guide before editing. For questions, suggestions, or technical issues, please contact Noah.

Module:ButtonBox: Difference between revisions

From CrabCraft Wiki
testing with generic data
Undo revision 969 by Max (talk)
Tag: Undo
 
(26 intermediate revisions by 2 users not shown)
Line 1: Line 1:
local p = {}
local p = {}
local cargo = mw.ext.cargo


function p.buttonbox()
function p.buttonbox()
-- local args = frame:getParent().args
    local tables = 'player_data'
local args = {{{[[File:Season4-End-Event-Banner.png|300px]], [[Main Page]], 'Main Page'}, {[[File:Season4-End-Event-Banner.png|300px]], [[Main Page]], 'Main Page'}} ,{{[[File:Season4-End-Event-Banner.png|300px]], [[Main Page]], 'Main Page'}, {[[File:Season4-End-Event-Banner.png|300px]], [[Main Page]], 'Main Page'}}}
    local fields = 'username'
local out = {}
    local args = {
table.insert(out,'{| class="buttonbox"')
        orderBy = 'username ASC',
table.insert(out, '|-\n')
        limit  = 100,
        groupBy = 'username'
for i, row in ipairs(args) do
    }
for j, button in ipairs(row) do
 
table.insert(out, '| <div class="buttonbox-entry">')
    local results = cargo.query(tables, fields, args)
table.insert(out, '<a href="' .. button[1] .. '"><img src="' .. button[2] .. '" alt="" /></a>')
 
table.insert(out, '<div class="buttonbox-label">' .. button[3] .. '</div></div>')
    local out   = { '{| class="buttonbox"' }
end
    local count = 1
end
 
    for _, row in ipairs(results) do
table.insert(out, '|}')
        local user = row.username
return table.concat(out, '\n')
        if user ~= '$1'
        and user ~= 'MHF_Steve'
        and user ~= 'BlockKnight32'
        then
            if (count - 1) % 7 == 0 then
                table.insert(out, '|-')
            end
 
            local image = 'https://mc-heads.net/avatar/' .. user .. '/100.png'
            local link  = '[[' .. user .. ']]'
            local cell  = '| <div class="buttonbox-entry">' ..
                            image ..
                            '<div class="buttonbox-label">' .. link .. '</div>' ..
                          ' </div>'
 
            table.insert(out, cell)
            count = count + 1
        end
    end
 
    table.insert(out, '|}')
    return table.concat(out, '\n')
end
end


return p
return p

Latest revision as of 21:19, 11 November 2025

Documentation for this module may be created at Module:ButtonBox/doc

local p = {}
local cargo = mw.ext.cargo

function p.buttonbox()
    local tables = 'player_data'
    local fields = 'username'
    local args = {
        orderBy = 'username ASC',
        limit   = 100,
        groupBy = 'username'
    }

    local results = cargo.query(tables, fields, args)

    local out   = { '{| class="buttonbox"' }
    local count = 1

    for _, row in ipairs(results) do
        local user = row.username
        if user ~= '$1'
        and user ~= 'MHF_Steve'
        and user ~= 'BlockKnight32'
        then
            if (count - 1) % 7 == 0 then
                table.insert(out, '|-')
            end

            local image = 'https://mc-heads.net/avatar/' .. user .. '/100.png'
            local link  = '[[' .. user .. ']]'
            local cell  = '| <div class="buttonbox-entry">' ..
                            image ..
                            '<div class="buttonbox-label">' .. link .. '</div>' ..
                           ' </div>'

            table.insert(out, cell)
            count = count + 1
        end
    end

    table.insert(out, '|}')
    return table.concat(out, '\n')
end

return p