3 local TourGuide
= TourGuide
7 TourGuide
.turnedin
= {}
9 local f
= CreateFrame("Frame")
10 f
:SetScript("OnEvent", function(self
, event
, ...) if self
[event
] then self
[event
](TourGuide
, event
, ...) end end)
13 function f
:CHAT_MSG_SYSTEM(event
, a1
)
14 local _
, _
, quest
= a1
:find("Quest accepted: (.*)")
15 if quest
and self
.actions
[self
.current
] == "ACCEPT" and self
.quests
[self
.current
] == quest
then return self
:UpdateStatusFrame() end
17 local _
, _
, questc
= a1
:find("(.*) completed.")
18 if questc
and self
.actions
[self
.current
] == "TURNIN" and self
.quests
[self
.current
] == questc
then
19 self
.turnedin
[questc
] = true
20 return self
:UpdateStatusFrame()
25 function f
:QUEST_COMPLETE(event
)
26 if self
.actions
[self
.current
] == "TURNIN" and GetQuestLogIndexByName(" "..self
.quests
[self
.current
]) then hadquest
= self
.quests
[self
.current
]
27 else hadquest
= nil end
31 function f
:UNIT_QUEST_LOG_UPDATE(event
, unit
)
32 if unit
~= "player" then return end
34 if hadquest
== self
.quests
[self
.current
] and not GetQuestLogIndexByName(" "..self
.quests
[self
.current
]) then self
:UpdateStatusFrame() end
39 function f
:QUEST_WATCH_UPDATE(event
)
40 if self
.actions
[self
.current
] ~= "COMPLETE" then return end
41 local i
= self
.current
43 local qi
= GetQuestLogIndexByName(" "..self
.quests
[i
])
44 if qi
and select(7, GetQuestLogTitle(qi
)) == 1 then RemoveQuestWatch(qi
) end
46 until self
.actions
[i
] ~= "COMPLETE"
50 local i
= GetQuestLogIndexByName(" "..self
.quests
[self
.current
])
51 if i
and select(7, GetQuestLogTitle(i
)) == 1 then return self
:UpdateStatusFrame() end
56 function f
:QUEST_FINISHED()
57 if self
.actions
[self
.current
] == "TURNIN" and GetQuestLogIndexByName(" "..self
.quests
[self
.current
]) then turninquest
= self
.quests
[self
.current
]
58 else turninquest
= nil end
62 function f
:QUEST_LOG_UPDATE(event
)
63 if self
.actions
[self
.current
] == "ACCEPT" then return self
:UpdateStatusFrame() end
64 if self
.actions
[self
.current
] == "TURNIN" and turninquest
== self
.quests
[self
.current
] and not GetQuestLogIndexByName(" "..turninquest
) then
65 TourGuide
.turnedin
[turninquest
] = true
66 return self
:UpdateStatusFrame()
68 if self
.actions
[self
.current
] ~= "COMPLETE" then return end
70 local i
= self
.current
72 local qi
= GetQuestLogIndexByName(" "..self
.quests
[i
])
73 if qi
and select(7, GetQuestLogTitle(qi
)) == 1 then RemoveQuestWatch(qi
) end
75 until self
.actions
[i
] ~= "COMPLETE"
79 local i
= GetQuestLogIndexByName(" "..self
.quests
[self
.current
])
80 if i
and select(7, GetQuestLogTitle(i
)) == 1 then return self
:UpdateStatusFrame() end
82 if self
.actions
[self
.current
] == "COMPLETE" then
83 local qi
= GetQuestLogIndexByName(" "..self
.quests
[self
.current
])
89 elseif self
.actions
[self
.current
] == "TURNIN" then
90 if not GetQuestLogIndexByName(" "..self
.quests
[self
.current
]) then return self
:UpdateStatusFrame() end
95 for i
in pairs(f
) do f
:RegisterEvent(i
) end