Module:Damage: Difference between revisions
From Elwiki
No edit summary |
No edit summary |
||
Line 8: | Line 8: | ||
local i = 1 | local i = 1 | ||
local tab = {} | local tab = {} | ||
for k | local tkeys = {} | ||
-- populate the table that holds the keys | |||
for k in frame:argumentPairs() do table.insert(tkeys, k) end | |||
-- sort the keys | |||
table.sort(tkeys) | |||
-- use the keys to retrieve the values in the sorted order | |||
for _, k in ipairs(tkeys) do | |||
tab = tab .. ' ' .. k | |||
end | end | ||
-- for k,v in frame:argumentPairs() do | |||
-- if string.starts(k, prefix) then | |||
-- if i == 1 then | |||
-- tab = k .. '=' .. v | |||
-- else | |||
-- tab = tab .. ', ' .. k .. '=' .. v | |||
-- end | |||
-- i = i + 1 | |||
-- end | |||
-- end | |||
return tab | return tab | ||
end | end |
Revision as of 21:49, 23 March 2022
Documentation for this module may be created at Module:Damage/doc
local getArgs = require('Module:Arguments').getArgs
local p = {}
function string.starts(String,Start)
return string.sub(String,1,string.len(Start))==Start
end
function forargs(frame, prefix)
local i = 1
local tab = {}
local tkeys = {}
-- populate the table that holds the keys
for k in frame:argumentPairs() do table.insert(tkeys, k) end
-- sort the keys
table.sort(tkeys)
-- use the keys to retrieve the values in the sorted order
for _, k in ipairs(tkeys) do
tab = tab .. ' ' .. k
end
-- for k,v in frame:argumentPairs() do
-- if string.starts(k, prefix) then
-- if i == 1 then
-- tab = k .. '=' .. v
-- else
-- tab = tab .. ', ' .. k .. '=' .. v
-- end
-- i = i + 1
-- end
-- end
return tab
end
function p.main(frame)
local args = getArgs(frame)
return forargs(frame, 'hits')
end
return p