Binding of Isaac: Rebirth Wiki
(Essai)
(Combo)
 
(76 versions intermédiaires par le même utilisateur non affichées)
Ligne 1 : Ligne 1 :
 
local p = {}
 
local p = {}
local rtext = require( 'Module:Text' )
+
local tableau = require( 'Module:Tableau' )
   
-- Split parameters string, e.g.: "ext: gif, size:12" --> { ext = "gif", size = "12" }
+
-- "ext: gif, taille:12" --> { ext = "gif", taille = "12" }
local function splitParams( initialString )
+
function p.separerParams( chaineInitiale )
local firstSplit = rtext.trimAll( mw.text.split( initialString, ',%s' ) )
+
local premiereSeparation = tableau.toutRogner( mw.text.split( chaineInitiale, ',%s' ) )
 
local param = {}
 
local param = {}
local allParam = {}
+
local tousParams = {}
for i, j in pairs( firstSplit ) do
+
for i, j in pairs( premiereSeparation ) do
param = rtext.trimAll( mw.text.split( j, ':' ) )
+
if j:find( ':' ) then
  +
param = tableau.toutRogner( mw.text.split( j, ':' ) )
allParam[param[1]] = param[2]
+
tousParams[param[1]] = param[2]
 
else
  +
tousParams[1] = j
 
end
 
end
 
end
return allParam
+
return tousParams
 
end
 
end
   
   
-- Split images string, e.g.: "(ext: gif, size:12 )(name:Box)" --> { 1 = "ext: gif, size:12", 2 = "name:Box" }
+
-- "( ext: gif, taille:12 )(nom : Case)" --> { 1 = "ext: gif, taille:12", 2 = "nom : Case" }
local function splitImages( initialString )
+
function p.separerImages( chaineInitiale )
local images = rtext.trimAll( rtext.trimAll( mw.text.split( initialString, '%(' ) ), '%)' )
+
local images = tableau.toutRogner( tableau.toutRogner( mw.text.split( chaineInitiale, '%(' ) ), '%)' )
 
local params = {}
 
local params = {}
local i = 2 -- 1st box of 'images' is empty
+
local i = 2 -- 1ère case de 'images' est vide
 
repeat
 
repeat
params[i-1] = splitParams( images[i] )
+
params[i-1] = p.separerParams( images[i] )
 
i = i + 1
 
i = i + 1
 
until not images[i]
 
until not images[i]
Ligne 28 : Ligne 32 :
   
   
local function merge( userParam, default )
+
local function fusionner( paramUtilisateur, default )
 
local param = {}
 
local param = {}
 
for i, j in pairs( default ) do
 
for i, j in pairs( default ) do
 
param[i] = j
 
param[i] = j
 
end
 
end
for k, l in pairs( userParam ) do
+
for k, l in pairs( paramUtilisateur ) do
 
param[k] = l
 
param[k] = l
 
end
 
end
Ligne 40 : Ligne 44 :
   
   
function p.main( f, default )
+
function p.main( f ) -- fonction dépréciée
 
return p.pcpl( f )
local args = rtext.trimAll( rtext.getArgs( f ) )
 
local ret = ''
 
local userParams = splitImages( args.params )
 
if args.image1 then
 
local params = {}
 
local i = 1
 
repeat
 
params[i] = splitParams( args['image'..i] )
 
i = i + 1
 
until not args['image'..i]
 
for k, l in pairs( userParams ) do
 
ret = ret .. p.data( merge( l, params[k] ) )
 
end
 
--[[else
 
ret = ret .. p.data( allParam )]]
 
end
 
return ret
 
 
end
 
end
   
 
function p.pcpl( f )
 
 
local args = tableau.toutRogner( tableau.obtenirArgs( f ) )
function p.data( f )
 
  +
if not args.params then error( 'Paramètre "params" manquant', 0 ) end
local args = rtext.trimAll( rtext.getArgs( f ) )
 
 
 
 
local renvoi = ''
local dataNameValue = { name=args.name, data=true }
 
  +
for i, j in pairs( p.separerImages( args.params ) ) do
if args.type then
 
  +
renvoi = renvoi .. p.donnees( args['par défaut'] and fusionner( args['image'..i] and fusionner( j, p.separerParams( args['image'..i] ) ) or j, p.separerParams( args['par défaut'] ) ) or args['image'..i] and fusionner( j, p.separerParams( args['image'..i] ) ) or j )
dataNameValue.type = args.type
 
 
end
 
end
local dataName = rtext.link( dataNameValue ).clean
 
local fileName = args.fullname or ( args.pfx or '' ):lower() .. ' ' .. dataName .. ' ' .. ( args.sfx or '' ):lower()
 
 
 
  +
return renvoi
local fileExt = '.' .. ( args.ext or 'png' )
 
 
end
 
  +
local size = { width = args.width, height = args.height }
 
  +
if args.type then
 
  +
function p.donnees( f )
for i, j in pairs( mw.loadData( 'Module:Data' ).imageSize[args.type] ) do
 
 
local args = tableau.toutRogner( tableau.obtenirArgs( f ) )
--[[if dataName == i then
 
 
local nomFichier = 'Image:' .. args.nom .. '.' .. ( args.ext or 'png' )
if args.id then
 
  +
return '[[' .. nomFichier .. '|' .. math.ceil( ( args.largeur or mw.getCurrentFrame():callParserFunction( '#imgw', nomFichier ) ) * ( args['échelle'] or 1 ) ) .. 'x' .. math.ceil( ( args.hauteur or mw.getCurrentFrame():callParserFunction( '#imgh', nomFichier ) ) * ( args['échelle'] or 1 ) ) .. 'px|' .. ( args.alignement or '' ) .. '|lien=' .. ( args.lien or '' ) .. '|' .. ( args.desc or '' ) .. ']]'
for k, l in pairs( j ) do
 
if id:lower() == k then
 
size.width = l[1]
 
size.height = l[2]
 
break
 
end
 
end
 
else
 
size.width = j[1][1]
 
size.height = j[1][2]
 
end
 
break
 
end]]size.width = 'aaa'
 
end
 
end
 
--[[local scale = args.scale or '1'
 
local fileSize = math.ceil( size.width * args.scale ) .. 'x' .. math.ceil( size.height * args.scale )
 
 
local fileAlign = args.align or 'center'
 
 
local fileLink = rtext.link({ name=args.name, data=true }).name .. '|' .. rtext.link({ name=args.name, data=true }).name]]
 
 
return size.width --.. 'x' .. size.height--'[[Image:' .. fileName .. fileExt '|' .. fileSize .. '|' .. fileAlign .. '|link=' .. fileLink .. ']]'
 
 
end
 
end
   

Dernière version du 20 février 2019 à 14:28

Missing No. Icon
Ce module est lié au projet Modèles.
Ne l'utilisez pas sur des pages du wiki non-liées à ce projet tant que celui-ci n'est pas terminé.



local p = {}
local tableau = require( 'Module:Tableau' )

--  "ext: gif, taille:12" --> { ext = "gif", taille = "12" }
function p.separerParams( chaineInitiale )
	local premiereSeparation = tableau.toutRogner( mw.text.split( chaineInitiale, ',%s' ) )
	local param = {}
	local tousParams = {}
	for i, j in pairs( premiereSeparation ) do
		if j:find( ':' ) then
			param = tableau.toutRogner( mw.text.split( j, ':' ) )
			tousParams[param[1]] = param[2]
		else
			tousParams[1] = j
		end
	end
	return tousParams
end


--  "( ext: gif, taille:12 )(nom : Case)" --> { 1 = "ext: gif, taille:12", 2 = "nom : Case" }
function p.separerImages( chaineInitiale )
	local images = tableau.toutRogner( tableau.toutRogner( mw.text.split( chaineInitiale, '%(' ) ), '%)' )
	local params = {}
	local i = 2   -- 1ère case de 'images' est vide
	repeat
		params[i-1] = p.separerParams( images[i] )
		i = i + 1
	until not images[i]
	return params
end


local function fusionner( paramUtilisateur, default )
	local param = {}
	for i, j in pairs( default ) do
		param[i] = j
	end
	for k, l in pairs( paramUtilisateur ) do
		param[k] = l
	end
	return param
end


function p.main( f ) -- fonction dépréciée
	return p.pcpl( f )
end

function p.pcpl( f )
	local args = tableau.toutRogner( tableau.obtenirArgs( f ) )
	if not args.params then error( 'Paramètre "params" manquant', 0 ) end
	
	local renvoi = ''
	for i, j in pairs( p.separerImages( args.params ) ) do
		renvoi = renvoi .. p.donnees( args['par défaut'] and fusionner( args['image'..i] and fusionner( j, p.separerParams( args['image'..i] ) ) or j, p.separerParams( args['par défaut'] ) ) or args['image'..i] and fusionner( j, p.separerParams( args['image'..i] ) ) or j )
	end
	
	return renvoi
end


function p.donnees( f )
	local args = tableau.toutRogner( tableau.obtenirArgs( f ) )
	local nomFichier = 'Image:' .. args.nom .. '.' .. ( args.ext or 'png' )
	return '[[' .. nomFichier .. '|' .. math.ceil( ( args.largeur or mw.getCurrentFrame():callParserFunction( '#imgw', nomFichier ) ) * ( args['échelle'] or 1 ) ) .. 'x' .. math.ceil( ( args.hauteur or mw.getCurrentFrame():callParserFunction( '#imgh', nomFichier ) ) * ( args['échelle'] or 1 ) ) .. 'px|' .. ( args.alignement or '' ) .. '|lien=' .. ( args.lien or '' ) .. '|' .. ( args.desc or '' ) .. ']]'
end

return p