Module:Calculator/AgilityObstacle: Difference between revisions

no edit summary
No edit summary
No edit summary
Line 129: Line 129:
end
end


-- Stupid shenanigans to filter out numeric parameters.
-- Because just iterating over #args doesn't work for some reason...
function getNumericArgs(args)
function getNumericArgs(args)
local ret = {}
for k, v in pairs(args) do
for k, v in pairs(args) do
k = tonumber(k)
if k then table.insert(ret, v) end
end
end
end
end
Line 140: Line 145:


function p._main(args)
function p._main(args)
for k, v in pairs(args) do
local numParams = getNumericArgs(args)
return tostring(k) .. '    ' .. tostring(v)
end
end
 
function p.a()
local obstacleNames = {}
local obstacleNames = {}
for i = 1, 20 do
for i = 1, #numParams do
     if args[i] then
     if numParams[i] then
     table.insert(obstacleNames, args[i]:match("^%s*(.-)%s*$"))
     table.insert(obstacleNames, numParams[i]:match("^%s*(.-)%s*$"))
     end
     end
end
end
2,875

edits