« Module:Fermentation » : différence entre les versions

De Les Archives de Vault-Tec
Kims (discussion | contributions)
Annulation des modifications 72900 de Kims (discussion)
Kims (discussion | contributions)
Aucun résumé des modifications
Ligne 25 : Ligne 25 :
:done()
:done()
:tag( 'li' )
:tag( 'li' )
:wikitext( '[[Fichier:Icon_range_inverse.png|x50px|center]]' )
:wikitext( '[[Fichier:Icon_range_inverse.png|x25px|center]]' )
:done()
:done()
end
end
Ligne 40 : Ligne 40 :
res:node(buildRow(value, def))
res:node(buildRow(value, def))
end
end
end
-- cas particulier l'inventaire du pnj est vide
if isEmpty then
res:node(buildRow(nil, data.vide))
end
end

Version du 19 juillet 2021 à 17:30

La documentation pour ce module peut être créée à Module:Fermentation/doc

local p = {}

local LF = '\n'

--------------------------------
-----     Référentiel      ----- 
--------------------------------

local data = {
	["fermentable"] = {	},
	["fermenté"] = {},
	["mature"] = {	}
}

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

function buildRow(argValue, def)
	local note = argValue or ''
	if note ~= '' then note = LF .. note .. LF end
	
	return mw.html.create( 'li' )
		:addClass( 'avt-interactions-text' )
		:tag( 'div' )
		:wikitext( note )
		:done()
		:tag( 'li' )
			:wikitext( '[[Fichier:Icon_range_inverse.png|x25px|center]]' )
		:done()
	end

function p._build(args)
	local res = mw.html.create( 'ul' )
		:addClass( 'avt-interactions' )
		local isEmpty = true
	
	for key, value in pairs(args) do
		local def = data[key:lower()]
		if def and value ~= '-' and value ~= 'vide' then
			isEmpty = false
			res:node(buildRow(value, def))
		end
	end
	
	res:allDone()
	
	return res
end

function p.build(frame)
	local args = {}
	
	local argsParent = frame:getParent().args
	for cle, val in pairs(argsParent) do
		if val then
			val = mw.text.trim(val)
			if val ~= '' then
				args[cle] = val
			end
		end
	end
	
	return p._build(args)
end

return p