Module:For loop: Difference between revisions

Implement merger with Template:ForCount
en>Pppery
m (Pppery moved page Module:ForLoop to Module:For loop without leaving a redirect: Make module name match template name)
en>Pppery
(Implement merger with Template:ForCount)
Line 62: Line 62:
function p.getVariableVals(args)
function p.getVariableVals(args)
local variableVals = {}
local variableVals = {}
for i, v in ipairs(args) do
if args.start or args.stop or args.by then
if i ~= 1 then
if args[2] then
variableVals[i - 1] = v
error("Both start/stop/by and numbered parameters specified")
end
start = tonumber(args.start or 1)
stop = tonumber(args.stop or 1)
by = tonumber(args.by or 1)
for i = start, stop, by do
variableVals [#variableVals + 1] = i
end
else
for i, v in ipairs(args) do
if i ~= 1 then
variableVals[i - 1] = v
end
end
end
end
end
Anonymous user