m (Name change part 3) |
No edit summary |
||
(15 intermediate revisions by 2 users not shown) | |||
Line 5: | Line 5: | ||
function p.GenerateTable(frame) |
function p.GenerateTable(frame) |
||
local args = getArgs(frame, {wrappers = 'Template:AchievementTable'}) |
local args = getArgs(frame, {wrappers = 'Template:AchievementTable'}) |
||
+ | |||
− | |||
if data[args.category] ~= nil then |
if data[args.category] ~= nil then |
||
local tableData = {} |
local tableData = {} |
||
Line 13: | Line 13: | ||
if isFirst then |
if isFirst then |
||
isFirst = false |
isFirst = false |
||
− | table.insert(tableData, "{| class='darktable sortable zebra plainlinks' align=center\n|-\n" .. (type(v) == "table" and "! Instance !" or "") .. "! Title !! class=unsortable | Description !! Rewards\n") |
+ | table.insert(tableData, frame:expandTemplate{ title = 'i-note', args = {data.lastUpdate}} .. "\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 |
||
Line 44: | Line 44: | ||
return table.concat(tableData) |
return table.concat(tableData) |
||
else |
else |
||
− | return args.category .. " does not exist in [[Module: |
+ | return args.category .. " does not exist in [[Module:AchievementTable/data]]" |
end |
end |
||
end |
end |
Latest revision as of 09:06, 2 April 2023
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 = {data.lastUpdate}} .. "\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