From 7143acac87e493762106872806a8246c5e70deb1 Mon Sep 17 00:00:00 2001 From: p3lim Date: Tue, 28 Dec 2010 02:18:10 +0100 Subject: [PATCH] Replace the table in favor for reading textures --- Automate.lua | 32 +++++++------------------------- 1 file changed, 7 insertions(+), 25 deletions(-) diff --git a/Automate.lua b/Automate.lua index 6989c93..d1268e8 100644 --- a/Automate.lua +++ b/Automate.lua @@ -1,7 +1,8 @@ local addon = CreateFrame('Frame') addon:SetScript('OnEvent', function(self, event, ...) self[event](...) end) -local activeQuests = {} +local AVAILABLE = [=[Interface\GossipFrame\AvailableQuestIcon]=] +local COMPLETE = [=[Interface\GossipFrame\ActiveQuestIcon]=] function addon:Register(event, func) self:RegisterEvent(event) @@ -12,21 +13,16 @@ function addon:Register(event, func) end end -local function QuestCompleted(title) - for quest, complete in pairs(activeQuests) do - if(title:find(quest) and complete) then - return true - end - end -end - addon:Register('GOSSIP_SHOW', function() for index = 1, NUMGOSSIPBUTTONS do local button = _G['GossipTitleButton' .. index] + if(button and button:IsVisible()) then - if(button.type == 'Available') then + local icon = _G['GossipTitleButton' .. index .. 'GossipIcon'] + + if(button.type == 'Available' and icon:GetTexture() == AVAILABLE) then return button:Click() - elseif(button.type == 'Active' and QuestCompleted(button:GetText())) then + elseif(button.type == 'Active' and icon:GetTexture() == COMPLETE) then return button:Click() end end @@ -53,20 +49,6 @@ addon:Register('QUEST_COMPLETE', function(...) end end) -addon:Register('QUEST_LOG_UPDATE', function(...) - wipe(activeQuests) - - local quests = GetNumQuestLogEntries() - if(quests > 0) then - for index = 1, quests do - local title, _, _, _, header, _, complete = GetQuestLogTitle(index) - if(title and not header) then - activeQuests[title] = complete or GetNumQuestLeaderBoards(index) == 0 - end - end - end -end) - addon:Register('UNIT_INVENTORY_CHANGED', function(unit) if(unit ~= 'player') then return end -- 1.7.9.5