Binding of Isaac: Rebirth Wiki
(Sans le mw ?)
(Ok)
Ligne 25 : Ligne 25 :
 
end
 
end
 
end
 
end
if not pexiste and not title.namespace then
+
if not pexiste and not mw.title.namespace then
 
_p = '[[Catégorie:Pages non répertoriées]]'
 
_p = '[[Catégorie:Pages non répertoriées]]'
elseif pexiste and title.namespace then
+
elseif pexiste and mw.title.namespace then
 
_p = '[[Catégorie:Pages répertoriées plusieurs fois]]'
 
_p = '[[Catégorie:Pages répertoriées plusieurs fois]]'
 
end
 
end
 
 
if pexiste and not title.namespace then
+
if pexiste and not mw.title.namespace then
 
if valeur.dlc == 'a' then
 
if valeur.dlc == 'a' then
 
if dlc[1] == 'a' or dlc[1] == 'no-a' then
 
if dlc[1] == 'a' or dlc[1] == 'no-a' then

Version du 13 mai 2017 à 16:56

Template-info Documentation

Fonction main( f )

Utilisée par le Modèle:Dlc. Cette fonction renvoie un icône de DLC et vérifie sa cohérence avec la page utilisée.
ArgumentsRenvois
f (frame)
  • Frame de la page utilisée.
  • Nécessite un paramètre non nommé :
    • Type : (string)
    • Abréviation du DLC demandé :
      • a pour Afterbirth
      • a+ pour Afterbirth†
      • bp 1 pour le Booster Pack 1.
  • Type : (string)
  • Icône de DLC correspondant à celle demandée et catégories supplémentaires.

Fonction icone( f )

Cette fonction renvoie une icône de DLC et est destinée à être utilisée dans des modules ou modèles.
ArgumentsRenvois
f (string)
  • Nom du DLC demandé.
  • Type : (string)
  • Icône du DLC correspondant ou catégorie d'erreur.
  • Renvoie une valeur nulle s'il ne possède aucun argument.

local p = {}

function p.main( f )
	local args = f:getParent().args
	local _p, _c = '', ''
	
	local mod = require( 'Module:Elements' )
	local pages = mod.all( args )
	local page = mw.title.getCurrentTitle()
	local nompage = page.text
	local element, valeur
	local pexiste = false
	
	local dlc = mw.text.split( args[1], '%s' )
	local titre = mw.title.getCurrentTitle()
	
	for index, objet in pairs(pages) do
		if index == nompage then
			if pexiste then
				_p = '[[Catégorie:Pages répertoriées plusieurs fois]]'
			else
				pexiste = true
				valeur = objet
			end
		end
	end
	if not pexiste and not mw.title.namespace then
		_p = '[[Catégorie:Pages non répertoriées]]'
	elseif pexiste and mw.title.namespace then
		_p = '[[Catégorie:Pages répertoriées plusieurs fois]]'
	end
	
	if pexiste and not mw.title.namespace then
		if valeur.dlc == 'a' then
			if dlc[1] == 'a' or dlc[1] == 'no-a' then
				_c = '[[Catégorie:Modèle dlc mal utilisé|' .. nompage .. ']]'
			elseif dlc[1] == 'a+' then
				_c = '<span title="Afterbirth †-contenu exclusif" style="cursor:help">[[Fichier:Afterbirth†_Indicator.png|lien=]]</span>'
			elseif dlc[1] == 'no-a+' then
				_c = '<span title="Rebirth-contenu exclusif" style="cursor:help">[[Fichier:NoDLC†_Indicator.png|lien=]]</span>'
			elseif dlc[1] == 'a-no-a+' then
				_c = '<span title="Rebirth-contenu exclusif" style="cursor:help">[[Fichier:NoDLC†_Indicator.png|lien=]]</span>[[Catégorie:Modèle dlc mal utilisé|' .. nompage .. ']]'
			elseif dlc[1] == 'bp' then
				_c = '<span title="Booster Pack ' .. dlc[2] .. '-contenu exclusif" style="cursor:help">[[Fichier:Afterbirth†_Booster_Pack_Indicator.png|lien=]]</span>'
			else
				_c = '[[Catégorie:Dlc inconnu]]'
			end
		elseif valeur.dlc == 'a+' then
			if dlc[1] == 'a' or dlc[1] == 'no-a' or dlc[1] == 'a+' or dlc[1] == 'no-a+' or dlc[1] == 'a-no-a+' then
				_c = '[[Catégorie:Modèle dlc mal utilisé|' .. nompage .. ']]'
			elseif dlc[1] == 'bp' then
				_c = '<span title="Booster Pack ' .. dlc[2] .. '-contenu exclusif" style="cursor:help">[[Fichier:Booster_Pack_Indicator.png|lien=]]</span>'
			else
				_c = '[[Catégorie:Dlc inconnu]]'
			end
		elseif valeur.dlc == 'bp' then
			if dlc[1] == 'a' or dlc[1] == 'no-a' or dlc[1] == 'a+' or dlc[1] == 'no-a+' or dlc[1] == 'a-no-a+' or dlc[1] == 'bp' then
				_c = '[[Catégorie:Modèle dlc mal utilisé|' .. nompage .. ']]'
			else
				_c = '[[Catégorie:Dlc inconnu]]'
			end
		else
			if dlc[1] == 'a' then
				_c = '<span title="Afterbirth-contenu exclusif" style="cursor:help">[[Fichier:DLC.png|lien=]]</span>'
			elseif dlc[1] == 'no-a' then
				_c = '<span title="Rebirth-contenu exclusif" style="cursor:help">[[Fichier:NoDLC_Indicator.png|lien=]]</span>'
			elseif dlc[1] == 'a+' then
				_c = '<span title="Afterbirth †-contenu exclusif" style="cursor:help">[[Fichier:Afterbirth†_Indicator.png|lien=]]</span>'
			elseif dlc[1] == 'no-a+' then
				_c = '<span title="Rebirth-contenu exclusif" style="cursor:help">[[Fichier:NoDLC†_Indicator.png|lien=]]</span>'
			elseif dlc[1] == 'a-no-a+' then
				_c = '<span title="Afterbirth-contenu exclusif" style="cursor:help">[[Fichier:DLC.png|lien=]]</span><span title="Afterbirth-contenu exclusif" style="cursor:help">[[Fichier:NoDLC†_Indicator.png|lien=]]</span>'
			elseif dlc[1] == 'bp' then
				_c = '<span title="Booster Pack ' .. dlc[2] .. '-contenu exclusif" style="cursor:help">[[Fichier:Afterbirth†_Booster_Pack_Indicator.png|lien=]]</span>'
			else
				_c = '[[Catégorie:Dlc inconnu]]'
			end
		end
	else
		if dlc[1] == 'a' then
			_c = '<span title="Afterbirth-contenu exclusif" style="cursor:help">[[Fichier:DLC.png|lien=]]</span>'
		elseif dlc[1] == 'no-a' then
			_c = '<span title="Rebirth-contenu exclusif" style="cursor:help">[[Fichier:NoDLC_Indicator.png|lien=]]</span>'
		elseif dlc[1] == 'a+' then
			_c = '<span title="Afterbirth †-contenu exclusif" style="cursor:help">[[Fichier:Afterbirth†_Indicator.png|lien=]]</span>'
		elseif dlc[1] == 'no-a+' then
			_c = '<span title="Rebirth-contenu exclusif" style="cursor:help">[[Fichier:NoDLC†_Indicator.png|lien=]]</span>'
		elseif dlc[1] == 'a-no-a+' then
			_c = '<span title="Afterbirth-contenu exclusif" style="cursor:help">[[Fichier:DLC.png|lien=]]</span><span title="Afterbirth-contenu exclusif" style="cursor:help">[[Fichier:NoDLC†_Indicator.png|lien=]]</span>'
		elseif dlc[1] == 'bp' then
			_c = '<span title="Booster Pack ' .. dlc[2] .. '-contenu exclusif" style="cursor:help">[[Fichier:Afterbirth†_Booster_Pack_Indicator.png|lien=]]</span>'
		else
			_c = '[[Catégorie:Dlc inconnu]]'
		end
	end
	
	return _c .. _p
end

function p.icon( f )
	local args = mw.text.split( f, '%s' )
	
	if args[1] ~= nil or args[1] ~= '' then
		if args[1] == 'Afterbirth' then
			return '<span title="Afterbirth-contenu exclusif" style="cursor:help">[[Fichier:DLC.png|lien=]]</span>'
		elseif args[1] == 'Afterbirth+' then
			return '<span title="Afterbirth †-contenu exclusif" style="cursor:help">[[Fichier:Afterbirth†_Indicator.png|lien=]]</span>'
		elseif args[1] == 'Booster' then
			return '<span title="Booster Pack ' .. args[3] .. '-contenu exclusif" style="cursor:help">[[Fichier:Afterbirth†_Booster_Pack_Indicator.png|lien=]]</span>'
			 --[[ args[3] car args[1]=="Booster" et args[2]=="Pack" (lié au mw.text.split) ]]
		else
			return '[[Catégorie:Dlc inconnu]]'
		end
	else
		return nil
	end
end

return p