Module:Case inventaire/Alias/Tableau

De Minecraft Wiki
Aller à : navigation, rechercher
[créer | historique | purger]Documentation
Ce module n'a pas de documentation. Si vous savez comment l'utiliser, merci de la créer.
local p = {}
p.table = function()
	local slot = require( [[Module:Case inventaire]] )
	local aliases = mw.loadData( [[Module:Case inventaire/Alias]] )
	
	local aliasNames = {}
	local aI = 1
	for name in pairs( aliases ) do
		-- Skip the banner aliases (except "Toute bannière"), as there are so
		-- many of them it causes the table to be excessively long
		if name == 'Toute bannière' or not name:find( '^Bannière' ) and not name:find( slot.i18n.prefixes.matching .. ' ' ) then
			aliasNames[aI] = name
			aI = aI + 1
		end
	end
	table.sort( aliasNames )
	
	local tableRows = {
		' {| class="wikitable collapsible collapsed"',
		'! Alias !! Résultat'
	}
	local rI = #tableRows + 1
	for _, name in ipairs( aliasNames ) do
		local alias = slot.getAlias( aliases[name], {} )
		
		local cell = {}
		for i, frame in ipairs( alias ) do
			cell[i] = slot.slot{ { frame }, parsed = true }
		end
		
		local aliasText = mw.html.create()
		aliasText:tag( 'code' ):wikitext( name )
		if name:find( slot.i18n.prefixes.any .. ' ' ) then
			aliasText:tag( 'br' ):done()
				:tag( 'code' ):wikitext( ( name:gsub( '^Toute?', 'Même' ) ) ) -- On garde l'accord
		end
		
		tableRows[rI] = '|' .. tostring( aliasText ) .. '||' .. table.concat( cell )
		rI = rI + 1
	end
	tableRows[rI] = '|}'
	
	return table.concat( tableRows, '\n|-\n' )
end
return p