Module:Redirect hatnote: Difference between revisions

From the Croc Wiki, the Croc encyclopedia
Jump to navigationJump to search
Content added Content deleted
(Ok, I think this got it)
(use a repeat ... until loop to avoid creating an unnecessary blank table)
Line 14: Line 14:
-- Get the args table and work out the maximum arg key.
-- Get the args table and work out the maximum arg key.


--[[
local origArgs = frame:getParent().args
local origArgs = frame:getParent().args
local args = {}
local args = {}
Line 25: Line 24:
if v ~= '' then
if v ~= '' then
args[k] = v
args[k] = v
end
end
--]]

local args = require('Module:Arguments').getArgs(frame)
local maxArg = 0
for k, v in pairs(args) do
if type(k) == 'number' and k > maxArg then
maxArg = k
end
end
end
end
Line 51: Line 41:
local iArg = 0
local iArg = 0
local iData = 1
local iData = 1
repeat
while iArg < maxArg do
iArg = iArg + 2
iArg = iArg + 2
local useTable = data[iData] or {}
local useTable = data[iData] or {}
Line 65: Line 55:
iData = iData + 1
iData = iData + 1
end
end
until iArg >= maxArg - 1
mw.logObject(useTable)
end


-- Create the options table.
-- Create the options table.