Módulo:Pn

Fonte: Enciclopédia de conhecimento da Igreja de Deus
Revisão em 01h16min de 14 de maio de 2024 por Jaewoo (discussão | contribs) (Criou a página com "--Module that returns one value from a list of unnamed parameters Named parameter idx is the index of the parameter that is to be returned Negative indices count backward from the end of the list == local p = {} p.getVal = function(frame) local args = {} -- copy arguments from frame object and its parent for k, v in pairs(frame.args) do args[k] = v end for k, v in pairs(frame:getParent().args) do args[k] = v end if not a...")
(dif) ← Revisão anterior | Revisão atual (dif) | Revisão seguinte → (dif)
Saltar para a navegação Saltar para a pesquisa

A documentação para este módulo pode ser criada na página Módulo:Pn/doc

--[[
Module that returns one value from a list of unnamed parameters
Named parameter idx is the index of the parameter that is to be returned
Negative indices count backward from the end of the list
==]]
local p = {}
p.getVal = function(frame)
				local args = {}
				-- copy arguments from frame object and its parent
				for k, v in pairs(frame.args) do
								args[k] = v
				end
				for k, v in pairs(frame:getParent().args) do
								args[k] = v
				end
				if not args[1] then
								return nil
				end
				local idx = tonumber(args.idx) or 1
				if idx < 0 then idx = #args + idx + 1 end
				return args[idx]
end
return p