Wowpedia

We have moved to Warcraft Wiki. Click here for information and the new URL.

READ MORE

Wowpedia
No edit summary
No edit summary
 
(9 intermediate revisions by the same user 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, frame:callParserFunction("i-note","test") .. "\n{| 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

Latest revision as of 09:06, 2 April 2023

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