« Module:Infobox/Core » : différence entre les versions
De Nefald
Autres actions
Coordonnées |
Aucun résumé des modifications |
||
| Ligne 55 : | Ligne 55 : | ||
body:node(sectionDiv) | body:node(sectionDiv) | ||
end | end | ||
-- Vérifier si on doit afficher les coordonnées automatiquement | |||
local hasCoordinates = args.x and args.x ~= '' and args.y and args.y ~= '' and args.z and args.z ~= '' | |||
local coordinatesDisplayed = false | |||
for _, champ in ipairs(section.champs or {}) do | for _, champ in ipairs(section.champs or {}) do | ||
-- | -- Détection automatique des coordonnées | ||
if champ.cle == ' | if hasCoordinates and not coordinatesDisplayed and (champ.cle == 'x' or champ.cle == 'y' or champ.cle == 'z' or champ.cle == 'spawn' or champ.cle == 'coordonnees') then | ||
local rowDiv = mw.html.create('div') | local rowDiv = mw.html.create('div') | ||
:addClass('infobox-row') | :addClass('infobox-row') | ||
| Ligne 64 : | Ligne 68 : | ||
local labelDiv = mw.html.create('div') | local labelDiv = mw.html.create('div') | ||
:addClass('infobox-label') | :addClass('infobox-label') | ||
:wikitext( | :wikitext('Coordonnées') | ||
local valueDiv = mw.html.create('div') | local valueDiv = mw.html.create('div') | ||
:addClass('infobox-value') | :addClass('infobox-value') | ||
-- Construction du lien vers la carte | -- Construction du lien vers la carte si le paramètre monde existe | ||
local mapUrl = string.format('[https://map.nefald.fr/?worldname=%s&mapname=surface&zoom=4&x=%s&y=%s&z=%s %s, %s, %s]', | if args.monde and args.monde ~= '' then | ||
local mapUrl = string.format('[https://map.nefald.fr/?worldname=%s&mapname=surface&zoom=4&x=%s&y=%s&z=%s %s, %s, %s]', | |||
args.monde, args.x, args.y, args.z, args.x, args.y, args.z) | |||
valueDiv:wikitext("''" .. mapUrl .. "''") | |||
else | |||
-- Affichage simple sans lien | |||
valueDiv:wikitext(string.format('%s, %s, %s', args.x, args.y, args.z)) | |||
end | |||
rowDiv:node(labelDiv):node(valueDiv) | rowDiv:node(labelDiv):node(valueDiv) | ||
body:node(rowDiv) | body:node(rowDiv) | ||
coordinatesDisplayed = true | |||
-- Traitement normal des autres champs | -- Traitement normal des autres champs (en excluant x, y, z individuels si coordonnées affichées) | ||
elseif args[champ.cle] and args[champ.cle] ~= '' then | elseif not (hasCoordinates and (champ.cle == 'x' or champ.cle == 'y' or champ.cle == 'z')) and args[champ.cle] and args[champ.cle] ~= '' then | ||
local rowDiv = mw.html.create('div') | local rowDiv = mw.html.create('div') | ||
:addClass('infobox-row') | :addClass('infobox-row') | ||