Module:Infobox: Difference between revisions

234 bytes added ,  11 years ago
custom step degree for touchParameters
m>Mr. Stradivarius
(shorter variable name for what is a pretty simple role, really)
m>Mr. Stradivarius
(custom step degree for touchParameters)
Line 249: Line 249:
end
end


-- This function parses the parameters with the given prefixes, in order, in batches of 20.
-- This function parses the parameters with the given prefixes, in order, in batches of the step size specified.
local function touchParameters(prefixTable, origArgs)
-- If the step size is not given, the default is 20.
local function touchParameters(prefixTable, origArgs, step)
     if type(prefixTable) ~= 'table' or type(origArgs) ~= 'table' then
     if type(prefixTable) ~= 'table' or type(origArgs) ~= 'table' then
         error("Invalid input to the touchParameters function detected. Both parameters must be tables.", 2)
         error("Invalid input to the touchParameters function detected. Both parameters must be tables.", 2)
     end
     end
    if step and type(step) ~= 'number' then
        error("Non-numerical step value detected.", 2)
    end
   
    step = step or 20
     local temp
     local temp
     local a = 1
     local a = 1
Line 265: Line 271:
     while moreArgumentsExist == true do
     while moreArgumentsExist == true do
         moreArgumentsExist = false
         moreArgumentsExist = false
         for i = a, a+19 do
         for i = a, a + step - 1 do
             for j,v in ipairs(prefixTable) do
             for j,v in ipairs(prefixTable) do
                 temp = origArgs[v .. tostring(i)]
                 temp = origArgs[v .. tostring(i)]
Line 273: Line 279:
             end
             end
         end
         end
         a = a + 20
         a = a + step
     end
     end
end
end
Line 292: Line 298:
     temp = origArgs.title
     temp = origArgs.title
     temp = origArgs.above
     temp = origArgs.above
     touchParameters({'subheader'}, origArgs)
     touchParameters({'subheader'}, origArgs, 5)
     touchParameters({'image', 'caption'}, origArgs)
     touchParameters({'image', 'caption'}, origArgs, 5)
     touchParameters({'header', 'label', 'data'}, origArgs)
     touchParameters({'header', 'label', 'data'}, origArgs, 20)
     temp = origArgs.below
     temp = origArgs.below
   
   
Anonymous user