From 2e577d25c8b9d3711caaa81f5748a930aefacb04 Mon Sep 17 00:00:00 2001 From: Adrian L Lange Date: Sun, 5 Feb 2012 15:43:55 +0100 Subject: [PATCH] Queue items if the cache doesn't have it yet --- Monomyth.lua | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/Monomyth.lua b/Monomyth.lua index 8d01436..9e2beba 100644 --- a/Monomyth.lua +++ b/Monomyth.lua @@ -85,6 +85,13 @@ Monomyth:Register('QUEST_PROGRESS', function() end end) +local choiceQueue, choiceFinished +Monomyth:Register('QUEST_ITEM_UPDATE', function(...) + if(choiceQueue) then + Monomyth.QUEST_COMPLETE() + end +end) + Monomyth:Register('QUEST_COMPLETE', function() if(GetNumQuestChoices() <= 1) then GetQuestReward(QuestFrameRewardPanel.itemChoice) @@ -93,24 +100,30 @@ Monomyth:Register('QUEST_COMPLETE', function() for index = 1, GetNumQuestChoices() do local link = GetQuestItemLink('choice', index) - if(not link) then - -- Item is not located in the cache yet, let it request it - -- from the server and run this again after its received - return - end - - local _, _, _, _, _, _, _, _, _, _, value = GetItemInfo(link) - if(value > bestValue) then - bestValue, bestIndex = value, index + if(link) then + local _, _, _, _, _, _, _, _, _, _, value = GetItemInfo(link) + if(value > bestValue) then + bestValue, bestIndex = value, index + end + else + choiceQueue = true + 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 +end) + Monomyth:Register('QUEST_AUTOCOMPLETE', function(id) local index = GetQuestLogIndexByID(id) if(GetQuestLogIsAutoComplete(index)) then -- 1.7.9.5