Module:Tableau des étapes de quête
La documentation pour ce module peut être créée à Module:Tableau des étapes de quête/doc
local p = {}
--------------------------------------
----- Fonctions communes -----
--------------------------------------
local CLASSES = 'va-table va-table-full va-table-center-col1 va-table-center-col2 mw-collapsible'
function getArgs(frame)
local args = {}
local argsParent = frame:getParent().args
for cle, val in pairs(argsParent) do
if val then
args[cle] = mw.text.trim(val)
end
end
return args
end
function formatStatus(status)
if status == 'terminée' then
status = '[[Fichier:Icon check.png|x14px|link=|alt=Quête terminée]]'
elseif status == 'échouée' then
status = '[[Fichier:Icon cross.png|x14px|link=|alt=Quête échouée]]'
end
return status
end
--------------------------------------
function p._questTableFo3(args)
res = mw.html.create( 'table' )
:addClass( CLASSES )
:tag( 'tr' )
:tag( 'th' ):wikitext( 'Étape' ):attr('style', 'width:4em;'):done()
:tag( 'th' ):wikitext( 'Statut' ):attr('style', 'width:4em;'):done()
:tag( 'th' ):wikitext( 'Entrée du journal' ):done()
:done()
local rows = ''
for i = 1, 50 do
local stage = args['étape' .. i]
local status = args['statut' .. i] or ''
local desc = args['desc' .. i] or ''
if stage then
status = formatStatus(status)
local row = mw.html.create( 'tr' )
:tag( 'td' ):wikitext( stage ):done()
:tag( 'td' ):wikitext( status ):done()
:tag( 'td' ):wikitext( desc ):done()
:done()
rows = rows .. tostring(row)
else
break
end
end
res :node( rows )
:allDone()
return res
end
function p._questTableFo4(args)
res = mw.html.create( 'table' )
:addClass( CLASSES )
:tag( 'tr' )
:tag( 'th' ):wikitext( 'Étape' ):attr('style', 'width:4em;'):done()
:tag( 'th' ):wikitext( 'Statut' ):attr('style', 'width:4em;'):done()
:tag( 'th' ):wikitext( 'Description' ):done()
:tag( 'th' ):wikitext( 'Entrée du journal' ):done()
:done()
local rows = ''
for i = 1, 50 do
local stage = args['étape' .. i]
local status = args['statut' .. i] or ''
local desc = args['desc' .. i] or ''
local log = args['entrée' .. i] or ''
if stage then
status = formatStatus(status)
local row = mw.html.create( 'tr' )
:tag( 'td' ):wikitext( stage ):done()
:tag( 'td' ):wikitext( status ):done()
:tag( 'td' ):wikitext( desc ):done()
:tag( 'td' ):wikitext( log ):done()
:done()
rows = rows .. tostring(row)
else
break
end
end
res :node( rows )
:allDone()
return res
end
-----------------------------------
----- Points d'entrée -----
-----------------------------------
function p.questTableFo3(frame) return p._questTableFo3(getArgs(frame)) end
function p.questTableFo4(frame) return p._questTableFo4(getArgs(frame)) end
return p