<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>https://secrets.warcraftwatch.com/w/index.php?action=history&amp;feed=atom&amp;title=Module%3AInstanceLootTable</id>
	<title>Module:InstanceLootTable - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://secrets.warcraftwatch.com/w/index.php?action=history&amp;feed=atom&amp;title=Module%3AInstanceLootTable"/>
	<link rel="alternate" type="text/html" href="https://secrets.warcraftwatch.com/w/index.php?title=Module:InstanceLootTable&amp;action=history"/>
	<updated>2026-05-06T18:50:02Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.44.0</generator>
	<entry>
		<id>https://secrets.warcraftwatch.com/w/index.php?title=Module:InstanceLootTable&amp;diff=7189&amp;oldid=prev</id>
		<title>imported&gt;Dragnog: Track the last difficulty inserted so we can check whether to add a middot or not after each difficulty</title>
		<link rel="alternate" type="text/html" href="https://secrets.warcraftwatch.com/w/index.php?title=Module:InstanceLootTable&amp;diff=7189&amp;oldid=prev"/>
		<updated>2023-12-02T19:16:34Z</updated>

		<summary type="html">&lt;p&gt;Track the last difficulty inserted so we can check whether to add a middot or not after each difficulty&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;local getArgs = require(&amp;#039;Module:Arguments&amp;#039;).getArgs&lt;br /&gt;
local p = {}&lt;br /&gt;
&lt;br /&gt;
function p.GenerateTable(frame)&lt;br /&gt;
	local args = getArgs(frame, {wrappers = &amp;#039;Template:InstanceLootTable&amp;#039;})&lt;br /&gt;
	&lt;br /&gt;
	if args.tier ~= nil and args.instance ~= nil then&lt;br /&gt;
		--Load instance data for the selected tier&lt;br /&gt;
		local data = mw.loadData(&amp;#039;Module:InstanceLootTable/data/&amp;#039;..args.tier)&lt;br /&gt;
		&lt;br /&gt;
		if data[args.instance] ~= null then	&lt;br /&gt;
			local tableData = {}&lt;br /&gt;
			local isFirst = true&lt;br /&gt;
			&lt;br /&gt;
			--Looping through all the encounters in the selected instance to get all loot items&lt;br /&gt;
			for k,v in pairs(data[args.instance]) do&lt;br /&gt;
				--Check if we just fetching a single boss&lt;br /&gt;
				if args.boss ~= nil then&lt;br /&gt;
					--Displaying just a single boss&lt;br /&gt;
					if args.boss == k then&lt;br /&gt;
						--Loop through all items to generate rows&lt;br /&gt;
						local firstItem = true;&lt;br /&gt;
						for item, difficulties in pairs(v) do&lt;br /&gt;
							--Get Difficulty data for item&lt;br /&gt;
							local instanceLootArgs = {}&lt;br /&gt;
							instanceLootArgs[&amp;#039;item&amp;#039;] = item&lt;br /&gt;
							local difficultyFound = false&lt;br /&gt;
							local lastDifficultyInserted = null&lt;br /&gt;
							for k, difficulty in ipairs(difficulties) do&lt;br /&gt;
								if difficulty ~= &amp;quot;n&amp;quot; then&lt;br /&gt;
									difficultyFound = true&lt;br /&gt;
									lastDifficultyInserted = difficulty&lt;br /&gt;
									instanceLootArgs[difficulty] = 1&lt;br /&gt;
								end&lt;br /&gt;
							end&lt;br /&gt;
							&lt;br /&gt;
							--If the item has no difficulty, then we should not display the () in Versions/InstanceLoot.&lt;br /&gt;
							if difficultyFound == false then&lt;br /&gt;
								instanceLootArgs[&amp;#039;nodifficulty&amp;#039;] = 1&lt;br /&gt;
							end&lt;br /&gt;
							&lt;br /&gt;
							--Track the last difficulty inserted so we can check whether to add a middot or not after each difficulty&lt;br /&gt;
							if lastDifficultyInserted ~= null then&lt;br /&gt;
								instanceLootArgs[&amp;#039;lastdifficulty&amp;#039;] = lastDifficultyInserted&lt;br /&gt;
							end&lt;br /&gt;
							&lt;br /&gt;
							--All rows&lt;br /&gt;
							table.insert(tableData, frame:callParserFunction(&amp;quot;#using:&amp;quot;..item,{&lt;br /&gt;
								&amp;quot;InstanceLootTable/list&amp;quot;,&lt;br /&gt;
								[&amp;quot;item&amp;quot;] = frame:expandTemplate{ title = &amp;#039;Versions/InstanceLoot&amp;#039;, args = instanceLootArgs },&lt;br /&gt;
							}))		&lt;br /&gt;
						end&lt;br /&gt;
					end&lt;br /&gt;
				else&lt;br /&gt;
					--Displaying all encounters for instance&lt;br /&gt;
					&lt;br /&gt;
					--Add row header&lt;br /&gt;
					if isFirst then&lt;br /&gt;
						isFirst = false&lt;br /&gt;
						table.insert(tableData, frame:expandTemplate{ title = &amp;#039;i-note&amp;#039;, args = {data.lastUpdate}} .. &amp;quot;\n{| class=&amp;#039;darktable sortable zebra plainlinks&amp;#039; align=center\n|-\n! Encounter !! Loot\n&amp;quot;)&lt;br /&gt;
					end&lt;br /&gt;
					&lt;br /&gt;
					--Calculate the rowspan for the encounter column by counting number of items&lt;br /&gt;
					local count = 0&lt;br /&gt;
					for i in pairs(v) do&lt;br /&gt;
						count = count + 1&lt;br /&gt;
					end&lt;br /&gt;
					&lt;br /&gt;
					--Loop through all items to generate rows&lt;br /&gt;
					local firstItem = true;&lt;br /&gt;
					local items = &amp;quot;&amp;quot;;&lt;br /&gt;
					for item, difficulties in pairs(v) do&lt;br /&gt;
						--Get Difficulty data for item&lt;br /&gt;
						local instanceLootArgs = {}&lt;br /&gt;
						instanceLootArgs[&amp;#039;item&amp;#039;] = item&lt;br /&gt;
						for k, difficulty in ipairs(difficulties) do&lt;br /&gt;
							if difficulty ~= &amp;quot;n&amp;quot; then&lt;br /&gt;
								instanceLootArgs[difficulty] = 1&lt;br /&gt;
							end&lt;br /&gt;
						end&lt;br /&gt;
						&lt;br /&gt;
						if firstItem then&lt;br /&gt;
							--Row including the encounter column&lt;br /&gt;
							table.insert(tableData, frame:callParserFunction(&amp;quot;#using:&amp;quot;..item,{&lt;br /&gt;
								&amp;quot;InstanceLootTable/row&amp;quot;,&lt;br /&gt;
								[&amp;quot;item&amp;quot;] = frame:expandTemplate{ title = &amp;#039;Versions/InstanceLoot&amp;#039;, args = instanceLootArgs },&lt;br /&gt;
								[&amp;quot;encounterRowspan&amp;quot;] = count,&lt;br /&gt;
								[&amp;quot;encounter&amp;quot;] = k&lt;br /&gt;
							}))&lt;br /&gt;
							firstItem = false;&lt;br /&gt;
						else&lt;br /&gt;
							--Rest of rows not including the encounter column&lt;br /&gt;
							table.insert(tableData, frame:callParserFunction(&amp;quot;#using:&amp;quot;..item,{&lt;br /&gt;
								&amp;quot;InstanceLootTable/row&amp;quot;,&lt;br /&gt;
								[&amp;quot;item&amp;quot;] = frame:expandTemplate{ title = &amp;#039;Versions/InstanceLoot&amp;#039;, args = instanceLootArgs },&lt;br /&gt;
							}))		&lt;br /&gt;
						end&lt;br /&gt;
					end&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
		&lt;br /&gt;
			if args.boss == null then&lt;br /&gt;
				table.insert(tableData, &amp;quot;\n|-\n|}&amp;quot;)&lt;br /&gt;
			end&lt;br /&gt;
			&lt;br /&gt;
			return table.concat(tableData)&lt;br /&gt;
			--return mw.text.jsonEncode(table.concat(tableData))&lt;br /&gt;
		else&lt;br /&gt;
			return args.instance .. &amp;quot; does not exist in [[Module:InstanceLootTable/data]]&amp;quot;	&lt;br /&gt;
		end&lt;br /&gt;
	else&lt;br /&gt;
		if args.tier == null then&lt;br /&gt;
			return &amp;quot; tier must be specified&amp;quot;&lt;br /&gt;
		elseif args.instance == null then&lt;br /&gt;
			return &amp;quot; instance must be specified&amp;quot;&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>imported&gt;Dragnog</name></author>
	</entry>
</feed>