Module:ButtonBox: Difference between revisions
Appearance
did not use capital letter in url Tag: Reverted |
hopefully fixed again thanks chatgpt Tag: Reverted |
||
| Line 24: | Line 24: | ||
local imageUrl = 'https://mc-heads.net/avatar/'..username..'/100.png' | local imageUrl = 'https://mc-heads.net/avatar/'..username..'/100.png' | ||
local | local imageTag = string.format('{{#tag:img||src=%s|width=100}}', imageUrl) | ||
local wrapped = '<div class="buttonbox-entry">' .. imageTag .. | |||
'<div class="buttonbox-label">' .. username .. '</div>' .. | |||
'</div>' | |||
local link = string.format('[[%s|%s]]', username, wrapped) | |||
local cell = '| ' .. link | local cell = '| ' .. link | ||
Revision as of 15:38, 24 June 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 -- Optional; remove or increase if needed
}
local results = cargo.query(tables, fields, args)
local out = {}
table.insert(out, '{| class="buttonbox"')
local count = 1
for _, row in ipairs(results) do
local username = row.username
if row.username ~= '$1' and row.username ~= 'MHF_Steve' and row.username ~= 'BlockKnight32' then
local url = mw.title.new(row.username):fullUrl()
if (count - 1) % 7 == 0 then
table.insert(out, '|-')
end
local imageUrl = 'https://mc-heads.net/avatar/'..username..'/100.png'
local imageTag = string.format('{{#tag:img||src=%s|width=100}}', imageUrl)
local wrapped = '<div class="buttonbox-entry">' .. imageTag ..
'<div class="buttonbox-label">' .. username .. '</div>' ..
'</div>'
local link = string.format('[[%s|%s]]', username, wrapped)
local cell = '| ' .. link
table.insert(out, cell)
count = count + 1
end
end
table.insert(out, '|}')
return mw.getCurrentFrame():preprocess(table.concat(out, '\n'))
end
return p