Wowpedia

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

READ MORE

Wowpedia
Advertisement
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, "{{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")
			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
Advertisement