Module:Redirect hatnote: Difference between revisions
From the Croc Wiki, the Croc encyclopedia
Jump to navigationJump to search
Content deleted Content added
still wrong, but slightly less wrong? |
increment iArg two at a time; better but still buggy |
||
Line 13: | Line 13: | ||
function p.redirect(frame) |
function p.redirect(frame) |
||
-- 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 23: | Line 25: | ||
if v ~= '' then |
if v ~= '' then |
||
args[k] = v |
args[k] = v |
||
⚫ | |||
⚫ | |||
--]] |
|||
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 38: | Line 49: | ||
-- Create the data table. |
-- Create the data table. |
||
local data = {} |
local data = {} |
||
local iArg = |
local iArg = 0 |
||
local iData = 1 |
local iData = 1 |
||
while iArg < maxArg do |
while iArg < maxArg do |
||
iArg = iArg + |
iArg = iArg + 2 |
||
local useTable = data[iData] or {} |
local useTable = data[iData] or {} |
||
local use |
local use = args[iArg] |
||
local page = args[iArg + 1] |
|||
⚫ | |||
use = args[iArg] |
|||
if use ~= 'and' then |
|||
⚫ | |||
isLastUse = true |
|||
⚫ | |||
else |
|||
page = args[iArg] |
|||
⚫ | |||
⚫ | |||
data[iData] = useTable |
data[iData] = useTable |
||
if |
if use ~= 'and' then |
||
⚫ | |||
iData = iData + 1 |
iData = iData + 1 |
||
end |
end |
||
mw.logObject(useTable) |
|||
end |
end |
||