« Module:Infobox/Armure gamebryo » : différence entre les versions

De Les Archives de Vault-Tec
Kharmitch (discussion | contributions)
mAucun résumé des modifications
Kharmitch (discussion | contributions)
Aucun résumé des modifications
Ligne 1 : Ligne 1 :
local localdata = require( 'Module:Infobox/Localdata' )
local localdata = require( 'Module:Infobox/Localdata' )
--------------------------------------------------------
-----              Fonctions communes              -----
--------------------------------------------------------
function buildObjectTable(index, objectName, hasSeparator)
local objectTable
if objectName or index == '' then
objectTable = { type = 'table', title = objectName, separator = hasSeparator, rows = {
{ type = 'row', label = 'Résistance aux dégâts', value = 'rd' .. index },
{ type = 'row', label = 'Résistance aux radiations', value = 'rr' .. index },
{ type = 'row', label = 'Résistance à l\'énergie', value = 're' .. index },
{ type = 'row', label = 'Seuil de dégâts', value = 'sd' .. index },
{ type = 'row', label = 'Points de vie', value = 'pv' },
{ type = 'row', label = 'Poids', value = 'poids' },
{ type = 'row', label = 'Valeur', value = 'valeur' },
{ type = 'row', label = 'Classe', value = 'classe' },
{ type = 'row', label = 'Variantes', value = 'variante' .. index },
{ type = 'row', label = 'Plan', value = 'plan' .. index },
{ type = 'row', label = 'Effets', value = 'effets' },
{ type = 'row', label = 'Réparation', value = { 'réparation' .. index, 'reparation' .. index }},
{ type = 'row', label = 'Editor ID', value = 'editorid' .. index },
{ type = 'row', label = '[[Form ID|Base ID]]', value = 'baseid' .. index }
}}
else
objectTable = { type = 'text' }
end
return objectTable
end


--------------------------------------------------------
--------------------------------------------------------
-----        Calcul des champs à afficher        -----
-----        Calcul des champs à afficher        -----
--------------------------------------------------------
--------------------------------------------------------
local games = (localdata['jeux'] or ''):lower()
local isFo3 = games:find('fo3') ~= nil
local isFnv = games:find('fnv') ~= nil


local objectName2 = localdata['nom objet2']
local objectName2 = localdata['nom objet2']
-- Résistance et seuil de dégâts
local rd, sd, rd2, sd2
if isFo3 then
rd = localdata['rd'] or '?'
if objectName2 then
rd2 = localdata['rd2'] or '?'
sd2 = nil
end
end
if isFnv then
rd = localdata['rd'] or nil
sd = localdata['sd'] or '?'
if objectName2 then
rd2 = localdata['rd2'] or nil
sd2 = localdata['sd2'] or '?'
end
end


-- Type d'armure ou vêtement
-- Type d'armure ou vêtement
Ligne 40 : Ligne 45 :
if objectName2 then
if objectName2 then
local cases = {
local cases = {
['armure']  = 'd\'armure',
['armure']  = 'Ensemble d\'armure',
['vêtement'] = 'de vêtement'
['tenue']    = 'Tenue',
['vêtement'] = 'Ensemble de vêtement'
}
}
ibSubject = 'Ensemble ' .. (cases[armorType] or 'd\'armure')
ibSubject = 'Ensemble ' .. (cases[armorType] or 'd\'armure')
Ligne 49 : Ligne 55 :
['casque']      = 'Casque',
['casque']      = 'Casque',
['couvre-chef'] = 'Couvre-chef',
['couvre-chef'] = 'Couvre-chef',
['tenue']      = 'Tenue',
['vêtement']    = 'Vêtement'
['vêtement']    = 'Vêtement'
}
}
Ligne 54 : Ligne 61 :
end
end


-- Gestion de l'affichage en fonction du type d'armure
if isUnique then
ibSubject = ibSubject .. ' unique'
end
 
-- Gestion de l'affichage des pièces d'armure


local objectTableLabel1, objectTable2
local objectTableLabel1


if objectName2 then
if objectName2 then
objectTableLabel1 = localdata['nom'] or require( 'Module:Outils' ).simpletitle(mw.getCurrentFrame())
objectTableLabel1 = localdata['nom'] or
require( 'Module:Outils' ).simpletitle(mw.getCurrentFrame())
objectTable2 = { type = 'table', title = objectName2, rows = {
{ type = 'row', label = 'Résistance aux dégâts', value = function() return rd2 end },
{ type = 'row', label = 'Seuil de dégâts', value = function() return sd2 end },
{ type = 'row', label = 'Points de vie', value = 'pv2' },
{ type = 'row', label = 'Poids', value = 'poids2' },
{ type = 'row', label = 'Valeur', value = 'valeur2' },
{ type = 'row', label = 'Classe', value = 'classe2' },
{ type = 'row', label = 'Effets', value = 'effets2' },
{ type = 'row', label = 'Réparation', value = { 'réparation2', 'reparation2' }},
{ type = 'row', label = '[[Form ID|Base ID]]', value = 'baseid2' },
}}
else
objectTable2 = { type = 'text' }
end
end


local objectTable1 = { type = 'table', title = objectTableLabel1, separator = objectTableLabel1 == nil, rows = {
local objectTable1 = buildObjectTable('', objectTableLabel1, objectTableLabel1 == nil)
{ type = 'row', label = 'Résistance aux dégâts', value = function() return rd end },
local objectTable2 = buildObjectTable('2', objectName2, false)
{ type = 'row', label = 'Seuil de dégâts', value = function() return sd end },
{ type = 'row', label = 'Points de vie', value = 'pv' },
{ type = 'row', label = 'Poids', value = 'poids' },
{ type = 'row', label = 'Valeur', value = 'valeur' },
{ type = 'row', label = 'Classe', value = 'classe' },
{ type = 'row', label = 'Effets', value = 'effets' },
{ type = 'row', label = 'Réparation', value = { 'réparation', 'reparation' }},
{ type = 'row', label = '[[Form ID|Base ID]]', value = 'baseid' },
}}


--------------------------------------------------------
--------------------------------------------------------

Version du 2 août 2021 à 01:00

Documentation du module

Ce module contient le paramétrage de l'infobox {{Infobox armure gamebryo}}.

Documentation transclues de Module:Infobox/Armure gamebryo/doc.
local localdata = require( 'Module:Infobox/Localdata' )

--------------------------------------------------------
-----              Fonctions communes              -----
--------------------------------------------------------

function buildObjectTable(index, objectName, hasSeparator)
	local objectTable
	if objectName or index == '' then
		objectTable = { type = 'table', title = objectName, separator = hasSeparator, rows = {
			{ type = 'row', label = 'Résistance aux dégâts', value = 'rd' .. index },
			{ type = 'row', label = 'Résistance aux radiations', value = 'rr' .. index },
			{ type = 'row', label = 'Résistance à l\'énergie', value = 're' .. index },
			{ type = 'row', label = 'Seuil de dégâts', value = 'sd' .. index },
			{ type = 'row', label = 'Points de vie', value = 'pv' },
			{ type = 'row', label = 'Poids', value = 'poids' },
			{ type = 'row', label = 'Valeur', value = 'valeur' },
			{ type = 'row', label = 'Classe', value = 'classe' },
			{ type = 'row', label = 'Variantes', value = 'variante' .. index },
			{ type = 'row', label = 'Plan', value = 'plan' .. index },
			{ type = 'row', label = 'Effets', value = 'effets' },
			{ type = 'row', label = 'Réparation', value = { 'réparation' .. index, 'reparation' .. index }},
			{ type = 'row', label = 'Editor ID', value = 'editorid' .. index },
			{ type = 'row', label = '[[Form ID|Base ID]]', value = 'baseid' .. index }
		}}
	else
		objectTable = { type = 'text' }
	end
	return objectTable
end

--------------------------------------------------------
-----         Calcul des champs à afficher         -----
--------------------------------------------------------

local objectName2 = localdata['nom objet2']

-- Type d'armure ou vêtement

local armorType = (localdata['type'] or 'armure'):lower()
local isUnique = armorType:find('unique')
local armorType = armorType:gsub(' unique', '')

local ibSubject
if objectName2 then
	local cases = {
		['armure']   = 'Ensemble d\'armure',
		['tenue']    = 'Tenue',
		['vêtement'] = 'Ensemble de vêtement'
	}
	ibSubject = 'Ensemble ' .. (cases[armorType] or 'd\'armure')
else
	local cases = {
		['armure']      = 'Armure',
		['casque']      = 'Casque',
		['couvre-chef'] = 'Couvre-chef',
		['tenue']       = 'Tenue',
		['vêtement']    = 'Vêtement'
	}
	ibSubject = cases[armorType] or 'Armure'
end

if isUnique then
	ibSubject = ibSubject .. ' unique'
end

-- Gestion de l'affichage des pièces d'armure

local objectTableLabel1

if objectName2 then
	objectTableLabel1 = localdata['nom'] or
			require( 'Module:Outils' ).simpletitle(mw.getCurrentFrame())
end

local objectTable1 = buildObjectTable('', objectTableLabel1, objectTableLabel1 == nil)
local objectTable2 = buildObjectTable('2', objectName2, false)

--------------------------------------------------------
-----          Construction de l'infobox           -----
--------------------------------------------------------

return {
	parts = {
		{ type = 'title', value = 'nom', subtitle = 'sous-titre', icon = 'icône', subhead = { games = 'jeux', subject = ibSubject, link = 'Armures et vêtements' }},
		{ type = 'images', imageparameters = { 'image', 'image2', 'image3', 'image4', 'image5' }, captionparameter = { 'légende', 'image desc' }},
		objectTable1,
		objectTable2,
		{ type = 'text', value = 'pied' }
	}
}