Quantcast

Allow required items to be filtered too

Adrian L Lange [06-17-13 - 00:38]
Allow required items to be filtered too
Filename
Config.lua
Monomyth.lua
diff --git a/Config.lua b/Config.lua
index c292a18..5b174e7 100644
--- a/Config.lua
+++ b/Config.lua
@@ -418,7 +418,11 @@ FilterPanel:SetScript('OnShow', function(self)
 				for slot = 1, GetContainerNumSlots(bag) do
 					if(GetContainerItemLink(bag, slot) == link) then
 						local _, questID = GetContainerItemQuestInfo(bag, slot)
-						if(questID) then
+						if(not questID) then
+							questID = string.format('progress_%s', itemID)
+						end
+
+						if(not MonomythDB.ignoredQuests[questID]) then
 							MonomythDB.ignoredQuests[questID] = itemID
 							ClearCursor()

diff --git a/Monomyth.lua b/Monomyth.lua
index 7602a5f..1b661bb 100644
--- a/Monomyth.lua
+++ b/Monomyth.lua
@@ -178,16 +178,34 @@ Monomyth:Register('QUEST_ACCEPTED', function(id)
 	end
 end)

-Monomyth:Register('QUEST_PROGRESS', function()
-	if(IsQuestCompletable()) then
-		CompleteQuest()
+local choiceQueue
+Monomyth:Register('QUEST_ITEM_UPDATE', function()
+	if(choiceQueue and Monomyth[choiceQueue]) then
+		Monomyth[choiceQueue]()
 	end
 end)

-local choiceQueue, choiceFinished
-Monomyth:Register('QUEST_ITEM_UPDATE', function(...)
-	if(choiceQueue) then
-		Monomyth.QUEST_COMPLETE()
+Monomyth:Register('QUEST_PROGRESS', function()
+	if(IsQuestCompletable()) then
+		local requiredItems = GetNumQuestItems()
+		if(requiredItems > 0) then
+			for index = 1, requiredItems do
+				local link = GetQuestItemLink('required', index)
+				if(link) then
+					local id = tonumber(string.match(link, 'item:(%d+)'))
+					for _, itemID in pairs(MonomythDB.ignoredQuests) do
+						if(itemID == id) then
+							return
+						end
+					end
+				else
+					choiceQueue = 'QUEST_PROGRESS'
+					return
+				end
+			end
+		end
+
+		CompleteQuest()
 	end
 end)

@@ -212,22 +230,19 @@ Monomyth:Register('QUEST_COMPLETE', function()
 					bestValue, bestIndex = value, index
 				end
 			else
-				choiceQueue = true
+				choiceQueue = 'QUEST_COMPLETE'
 				return GetQuestItemInfo('choice', index)
 			end
 		end

 		if(bestIndex) then
-			choiceFinished = true
 			_G['QuestInfoItem' .. bestIndex]:Click()
 		end
 	end
 end)

 Monomyth:Register('QUEST_FINISHED', function()
-	if(choiceFinished) then
-		choiceQueue = false
-	end
+	choiceQueue = nil
 end)

 Monomyth:Register('QUEST_AUTOCOMPLETE', function(id)