« Module:MinecraftConnect » : différence entre les versions
De Nefald
Autres actions
m échappement |
Aucun résumé des modifications |
||
| (9 versions intermédiaires par le même utilisateur non affichées) | |||
| Ligne 1 : | Ligne 1 : | ||
local p = {} | local p = {} | ||
function p. | function p.button(frame) | ||
-- Récupération des arguments | |||
local args = frame.args | |||
-- Récupération des | if not args[1] and frame:getParent() then | ||
local | args = frame:getParent().args | ||
end | end | ||
local server = mw.text.trim(args[1] or args.serveur or 'play.exemple.fr') | |||
local | local port = mw.text.trim(args[2] or args.port or '25565') | ||
local texte = mw.text.trim(args[3] or args.texte or "Copier l'adresse") | |||
local | |||
local | |||
-- | -- Construction de l'adresse complète | ||
local adresseComplete = (port == '25565') and server or (server .. ':' .. port) | |||
-- | -- Création d'un simple span avec data attributes (comme PreToClip) | ||
local | local container = mw.html.create('span') | ||
:addClass('minecraft-connect-wrapper') | |||
:attr('data-mc-server', adresseComplete) | |||
:attr('data-mc-text', texte) | |||
:wikitext(texte .. ' 📋') | |||
return tostring(container) | |||
return | |||
end | end | ||
return p | return p | ||
Dernière version du 10 novembre 2025 à 13:51
La documentation pour ce module peut être créée à Module:MinecraftConnect/doc
local p = {}
function p.button(frame)
-- Récupération des arguments
local args = frame.args
if not args[1] and frame:getParent() then
args = frame:getParent().args
end
local server = mw.text.trim(args[1] or args.serveur or 'play.exemple.fr')
local port = mw.text.trim(args[2] or args.port or '25565')
local texte = mw.text.trim(args[3] or args.texte or "Copier l'adresse")
-- Construction de l'adresse complète
local adresseComplete = (port == '25565') and server or (server .. ':' .. port)
-- Création d'un simple span avec data attributes (comme PreToClip)
local container = mw.html.create('span')
:addClass('minecraft-connect-wrapper')
:attr('data-mc-server', adresseComplete)
:attr('data-mc-text', texte)
:wikitext(texte .. ' 📋')
return tostring(container)
end
return p