Module:DLCLink

De ARK Wiki
Aller à la navigation Aller à la recherche
Template-info.png Documentation

Contrôle si le nom contient un suffixe de DLC et ajoute l'icône du DLC correspondant, puis retourne le lien en nom. Est utilisé par divers modèles utilisant les noms contenant des suffixes, comme le Modèle:ItemLink dans l'exemple ci-dessous.

Exemple

{{ItemLink|Champignon aquatique (Aberration)}}

Donne:

 Champignon aquatique (Aberration)


-- Checks if the name contains a DLC-suffix and changes it to the according DLC-icon, then returns a link to name.

local p = {}

local tryMatch = require('en:DissectDlcItemName').tryMatch


function p.link(name, noDlcIcon)
  -- Contrôle les infos du nom du DLC avec DissectDlcItemName
  local info = tryMatch(name)
  if info then
  	return '[['..name..'|'..info.displayName..']]'.. ((not noDlcIcon) and ' [[File:'..info.dlcIcon..'|16px|link='..info.dlcArticle..'|alt=('..info.dlcArticle..')]]' or '')
  end

  -- si aucun DLC n'est trouvé, utilise une approche générique
  local title = mw.title.new(name)
  if title == nil then
    return 'page non trouvée: ' .. name
  end
  local link = (#title.nsText > 0) and (title.fullText .. '|' .. title.text) or title.text
  return '[['..link..']]'
end


return p