Replace the table in favor for reading textures
p3lim [12-28-10 - 01:18]
Replace the table in favor for reading textures
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