No edit summary |
No edit summary |
||
Line 13: | Line 13: | ||
if isFirst then |
if isFirst then |
||
isFirst = false |
isFirst = false |
||
− | table.insert(tableData, frame: |
+ | table.insert(tableData, frame:expandTemplate{ title = 'i-note', args = { 'Test',}} .. "\n{| class='darktable sortable zebra plainlinks' align=center\n|-\n" .. (type(v) == "table" and "! Instance !" or "") .. "! Title !! class=unsortable | Description !! Rewards\n") |
end |
end |
||
if type(v) == "table" then |
if type(v) == "table" then |
Revision as of 18:30, 4 August 2021
See {{AchievementTable}}, {{AchievementTable/row}} and Module:AchievementTable/data.
local getArgs = require('Module:Arguments').getArgs
local p = {}
local data = mw.loadData('Module:AchievementTable/data')
function p.GenerateTable(frame)
local args = getArgs(frame, {wrappers = 'Template:AchievementTable'})
if data[args.category] ~= nil then
local tableData = {}
local isFirst = true
for k,v in pairs(data[args.category]) do
if isFirst then
isFirst = false
table.insert(tableData, frame:expandTemplate{ title = 'i-note', args = { 'Test',}} .. "\n{| class='darktable sortable zebra plainlinks' align=center\n|-\n" .. (type(v) == "table" and "! Instance !" or "") .. "! Title !! class=unsortable | Description !! Rewards\n")
end
if type(v) == "table" then
local count
for i in ipairs(v) do
count = i
end
table.insert(tableData, frame:callParserFunction("#using:"..v[1],{
"AchievementTable/row",
["link"] = v[1],
["instanceRowspan"] = count,
["instance"] = k == "" and "~" or k:gsub("!","!"), -- Converts "" to "~" and escapes MOTHERLODE!!
}))
for i=2, count do
table.insert(tableData, frame:callParserFunction("#using:"..v[i],{
"AchievementTable/row",
["link"] = v[i],
}))
end
else -- if type(v) == "string" then
table.insert(tableData, frame:callParserFunction("#using:"..v,{
"AchievementTable/row",
["link"] = v,
}))
end
end
table.insert(tableData, "\n|-\n|}")
return table.concat(tableData)
else
return args.category .. " does not exist in [[Module:AchievementTable/data]]"
end
end
return p