Módulo:Parameter alias
Ir para navegação
Ir para pesquisar
Documentação do módulo
Esta documentação é transcluída de Módulo:Parameter alias/doc. [editar] [atualizar]
Módulo:Parameter alias requer Módulo:Paramtest.
Módulo:Parameter alias é solicitado por Módulo:Infobox objeto.
A simple way to alias several parameters together.
Este módulo é um módulo de apoio para ser usado por outros módulos; ele pode não ser projetado para ser invocado diretamente. See RuneScape:Lua/Helper modules for a full list and more information. Para uma lista completa de módulos usando esse apoio clique aqui
Módulo | Função | Tipo | Uso | |
---|---|---|---|---|
Parameter alias | alias(arg1, arg2, arg3, ..., argN) | any | Returns the first argument in the varargs that satisfies paramtest.has_content (i.e. the first input that is not nil or whitespace). Returns nil if no argument satisfies it. | |
alias_alt(func, arg1, arg2, arg3, ..., argN) | any | Returns the first argument in the varargs satisfies the given func (the first argument). func(x) should be a function that returns a boolean based on x. |
- Example
Note that there is no limit to the number of arguments you can provide.
local par_al= require('Módulo:Parameter alias') local infobox = require('Módulo:Infobox') local p ={} function p.test(args) -- using paramtest.has_content, the default - will return the first of these three that is not whitespace or nil local examine = par_al.alias(args['examinar'], args['examine'], args['description']) -- using alias_alt, to provide an alternative function -- this one will return the first that can be parsed into a number local level = par_al.alias_alt(tonumber, args['nível'], args['nivel'], args['level']) -- useful when writing infoboxes -- uses the infobox standard of defined, which is not nil, whitespace, or an edit button local something = par_al.alias_alt(infobox.isDefined, args['ex1'], args['ex2']) -- custom function example -- returns the first thing that is not a function customExample(x) return not (x == 'a') end local not_a = par_al.alias_alt(customExample, args[1], args[2], args[3], args[4], args[5]) end return p