Aucun résumé des modifications |
Aucun résumé des modifications |
||
Ligne 176 : | Ligne 176 : | ||
return _i |
return _i |
||
else |
else |
||
− | return args[1] == |
+ | return _i .. ( args[1] == 'utilisation unique' and 'Utilisation unique' or args[1] == 'infinie' and 'Infinie' or string.find( args[1], 's' ) and ' ' .. mw.text.trim( args[1], 's' ) .. ' secondes' or args[1] ) |
end |
end |
||
end |
end |
Version du 25 novembre 2017 à 21:18
Fonction
| |
---|---|
Cette fonction met en place la structure d'un module fiche. | |
Arguments | Renvois |
|
|
Fonction
| |
---|---|
Cette fonction gère l'affichage du titre d'une fiche. | |
Arguments | Renvois |
|
|
Fonction
| |
---|---|
Cette fonction renvoie un fichier selon les paramètres entrés par l'utilisateur. | |
Arguments | Renvois |
|
|
Fonction
| |
---|---|
Cette fonction affiche la citation d'un élément. | |
Arguments | Renvois |
|
|
Fonction
| |
---|---|
Cette fonction affiche la recharge d'un objet activable. | |
Arguments | Renvois |
|
|
Fonction
| |
---|---|
Cette fonction renvoie une grille de collection, la case demandée sélectionnée. | |
Arguments | Renvois |
|
|
La documentation ci-haut est transcluse de Module:Fiche/doc. (modifier | historique)
local p = {}
local Tableau
local modElements = require( 'Module:Elements' )
local police = require( 'Module:Police' )
function p.mode( f, listeModes )
local moduleFiche = require( f:getTitle() )
local args = moduleFiche.args( f )
local disp = mw.text.split( args.disp, '-')
local page = modElements.page( args.nom )
local modes = {}
for index, objet in pairs( args ) do
if objet == '' then
args[index] = nil
end
end
if not page.valeur.dlc then
page.valeur.dlc = ''
end
if disp[2] == 'dlc' then
page.valeur.dlc = args.dlc
elseif disp[2] == 'nodlc' then
page.valeur.dlc = 'Booster Pack 10'
end
if listeModes then
local tableauModes = mw.text.split( listeModes, '%s/%s' )
local i = 1
repeat
modes[tableauModes[i]] = true
i = i + 1
until not tableauModes[i]
end
if args.temp == args.nom or args.temp == '{{{1}}}' then
if args.disp == '{{{2}}}' then
return moduleFiche.fiche( args, page )
elseif disp[1] == 'case' and modes.case then
return moduleFiche.case( args, page )
elseif disp[1] == 'nom' and modes.nom then
return moduleFiche.nom( args, page )
elseif disp[1] == 'tableau' and modes.tableau then
if disp[2] == 'simple' and modes.tableauSimple or disp[3] == 'simple' and modes.tableauSimple then
return moduleFiche.tableauSimple( args, page )
else
return moduleFiche.tableau( args, page )
end
elseif disp[1] == 'phraseIntro' and modes.phraseIntro then
return moduleFiche.intro( args )
else
return "''Mode d'affichage inconnu <sup>[<nowiki/>[" .. args.nom .. "]<nowiki/>]</sup>'' [[Catégorie:Mode de fiche inconnu]]"
end
end
end
function p.nom( nom, remplaceNom, mode )
local nomFinal = remplaceNom or nom
if remplaceNom ~= nil and remplaceNom ~= '' then
nomFinal = remplaceNom
end
if mode == 1 then
return nom .. '|' .. nomFinal
elseif mode == 2 then
return '[[' .. nom .. '|' .. nomFinal .. ']]'
elseif mode == 3 then
return nomFinal
else
return police.titre( 'TeamMeat', nomFinal, 2 )
end
end
function p.image( nom, remplaceNom, remplaceImage, _t, lien, _sD, _sF, _e )
local n = 1
local _i = nom
local _l = ''
local autres = false
_e = _e or '.png'
if remplaceImage ~= nil and remplaceImage ~= '' then
local image = mw.text.split( remplaceImage, '%s' )
if image[1] then
repeat
if image[n]:reverse():find( '%.', image[n]:len()-2 ) then
_e = image[n]
elseif image[n]:find( 'px', image[n]:len()-3 ) or image[n]:find( '%%', image[n]:len()-2 ) then
_t = image[n]
elseif not autres then
_i = image[n]
autres = true
else
_c = '[[Catégorie:Paramètres d\'image inconnus]]'
end
n = n + 1
until not image[n]
end
end
if lien then
_l = p.nom( nom, remplaceNom, 1 )
else
_l = ''
end
return '[[Image:' .. _sD .. _i .. _sF .. _e .. '|' .. _t .. '|lien=' .. _l .. ']]'
end
function p.citation( citation, italique )
local phrase
local _c = ''
if citation:find( 'vf' ) then
phrase = mw.text.split( citation, '%)%s' )
phrase[1] = mw.text.trim( phrase[1], 'vo%(' )
phrase[2] = mw.text.trim( phrase[2], 'vf%(' )
phrase[2] = mw.text.trim( phrase[2], '%)' )
if italique then
_c = "[[Fichier:Drapeau_EN.png|18px|lien=|Texte original]] ''\"" .. phrase[1] .. "\"''<br/>[[Fichier:Drapeau_FR.png|18px|lien=|Traduction française]] ''\"" .. phrase[2] .. "\"''"
else
_c = '[[Fichier:Drapeau_EN.png|18px|lien=|Texte original]] "' .. phrase[1] .. '"<br/>[[Fichier:Drapeau_FR.png|18px|lien=|Traduction française]] "' .. phrase[2] .. '"'
end
else
phrase = mw.text.trim( citation, 'vo%(' )
phrase = mw.text.trim( citation, '%)' )
if italique then
_c = "''\"" .. phrase .. "\"''"
else
_c = '"' .. phrase .. '"'
end
end
return _c
end
function p.recharge( recharge, mode )
local args = mw.text.split( recharge, ',%s' )
local _i = ''
local imgParam
if mode == 1 then
imgParam = '|15px|lien='
else
imgParam = '|6px|lien='
end
if args[1] == '1' then
_i = '[[Image:Recharge_1.png' .. imgParam .. '|Recharge à 1 cran]]'
elseif args[1] == '2' then
_i = '[[Image:Recharge_2.png' .. imgParam .. '|Recharge à 2 crans]]'
elseif args[1] == '3' then
_i = '[[Image:Recharge_3.png' .. imgParam .. '|Recharge à 3 crans]]'
elseif args[1] == '4' then
_i = '[[Image:Recharge_4.png' .. imgParam .. '|Recharge à 4 crans]]'
elseif args[1] == '6' then
_i = '[[Image:Recharge_6.png' .. imgParam .. '|Recharge à 6 crans]]'
elseif args[1] == '12' then
_i = '[[Image:Recharge_12.png' .. imgParam .. '|Recharge à 12 crans]]'
elseif args[1] == 'utilisation unique' then
_i = '[[Image:Recharge_one_time.png' .. imgParam .. '|Utilisation unique]]'
elseif args[1] == 'infinie' then
_i = '[[Image:Recharge_unlimited.png' .. imgParam .. '|Infinie]]'
elseif string.find( args[1], 's' ) then
_i = '[[Image:Recharge_time.png' .. imgParam .. '|Recharge en ' .. mw.text.trim( args[1], 's' ) .. ' secondes]]'
end
if mode == 1 then
return _i
else
return _i .. ( args[1] == 'utilisation unique' and 'Utilisation unique' or args[1] == 'infinie' and 'Infinie' or string.find( args[1], 's' ) and ' ' .. mw.text.trim( args[1], 's' ) .. ' secondes' or args[1] )
end
end
function p.grilleCollection( grille, maxColonne, maxLigne, texte )
local args = mw.text.split( grille, '%s' )
local colonne = tonumber( args[2] )
local ligne = tonumber( args[3] )
local _t = ''
local _g = ''
if texte then
_t = '(page ' .. args[1] .. ', colonne ' .. args[2] .. ', ligne ' .. args[3] .. ')'
end
_g = '\n<table class="wikitable" style="margin:1em auto 1em auto; line-height:0">'
for i=1, maxLigne, 1 do
if ligne == i then
_g = _g .. '<tr style="background-color:#CCC">'
else
_g = _g .. '<tr>'
end
for j=1, maxColonne, 1 do
if colonne == j and ligne == i then
_g = _g .. '<td style="background-color:#888"></td>'
elseif colonne == j then
_g = _g .. '<td style="background-color:#CCC"></td>'
else
_g = _g .. '<td></td>'
end
end
_g = _g .. '</tr>'
end
_g = _g .. '</table>'
return _t .. _g
end
return p