Module:Sandbox/ChaoticShadow/SongDataLine: Difference between revisions
Content added Content deleted
No edit summary |
No edit summary |
||
Line 5: | Line 5: | ||
local root = mw.html.create('table'):addClass('wikitable') |
local root = mw.html.create('table'):addClass('wikitable') |
||
local others = '' |
|||
function p.main(frame) |
function p.main(frame) |
||
Line 17: | Line 15: | ||
jp = { |
jp = { |
||
pattern = "^jp[0-9]+$", |
pattern = "^jp[0-9]+$", |
||
tb = {} |
tb = {} |
||
base = 1 |
|||
}, |
}, |
||
en = { |
en = { |
||
pattern = "^en[0-9]+$", |
pattern = "^en[0-9]+$", |
||
tb = {} |
tb = {} |
||
base = 1 |
|||
} |
} |
||
} |
} |
||
for k,v in pairs(args) do |
for k,v in pairs(args) do |
||
for _,lang in ipairs(tbls) do |
|||
if string.match(k, "^jp[0-9]+$") then |
|||
if string.match(k, lang.pattern) then |
|||
ind = tonumber(string.match(k, "[0-9]+")) |
|||
⚫ | |||
tbls.jp.base = tbls.jp.base + 1 |
|||
⚫ | |||
break |
|||
end |
end |
||
⚫ | |||
⚫ | |||
elseif string.match(k, "^en[0-9]+$") then |
|||
else |
|||
others = others .. k .. ',' .. v .. '\n' |
|||
end |
end |
||
end |
end |
||
Line 49: | Line 43: | ||
end |
end |
||
return tostring(root) .. mw.dumpObject(tbls) |
return tostring(root) .. mw.dumpObject(tbls) .. mw.dumpObject(args) .. #tbls.jp.tb |
||
end |
end |
||
Revision as of 02:11, 24 June 2021
Documentation for this module may be created at Module:Sandbox/ChaoticShadow/SongDataLine/doc
local getArgs = require('Module:Arguments').getArgs
local p = {}
local args = {}
local root = mw.html.create('table'):addClass('wikitable')
function p.main(frame)
args = getArgs(frame)
tbl1 = {}
base1 = 1
tbl2 = {}
tbls = {
jp = {
pattern = "^jp[0-9]+$",
tb = {}
},
en = {
pattern = "^en[0-9]+$",
tb = {}
}
}
for k,v in pairs(args) do
for _,lang in ipairs(tbls) do
if string.match(k, lang.pattern) then
ind = tonumber(string.match(k, "[0-9]+"))
lang.tb[ind] = v
break
end
end
end
for i=1,#tbls.jp.tb,1 do
if tbls.jp.tb[i] then
root:tag('tr'):tag('td'):wikitext(tbls.jp.tb[i])
else
break
end
end
return tostring(root) .. mw.dumpObject(tbls) .. mw.dumpObject(args) .. #tbls.jp.tb
end
return p