View Single Post
04-08-24, 05:12 AM   #8
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,960
What does it do ?
What did you expect it to do ?

It doesn't work doesn't explain what is happening in your case.

Looking at your code you are still only setting the information on PLAYER_LOGIN. This means it will only show the status ( outside of the printed statements from my code portions) when you first login or reload the UI.

Your updating of the display code needs to be updated on completion too.

Give this code a whirl. It's not perfect but hopefully it will work closer to what you wanted it to do.

Lua Code:
  1. local addonName, addon = ...
  2.  
  3. -- Create Frame
  4. local frame = CreateFrame("Frame", "QuestCompletionFrame", UIParent)
  5. frame:SetSize(100, 100)
  6. frame:SetPoint("CENTER")
  7. frame:EnableMouse(true)
  8. frame:SetMovable(true)
  9. frame:RegisterForDrag("LeftButton")
  10. frame:SetScript("OnDragStart", frame.StartMoving)
  11. frame:SetScript("OnDragStop", frame.StopMovingOrSizing)
  12.  
  13. local text = frame:CreateFontString(nil, "OVERLAY", "GameFontNormal")
  14. text:SetPoint("CENTER")
  15.  
  16. -- Initialise Data used in addon
  17. local completedQuests = {}
  18. local questInfo = {}
  19. local questIDs = {70893, 71995}
  20.  
  21. -- Setup Localization
  22. local localization = {
  23.     ["enUS"] = {
  24.         ["quest70893"] = "|cFFDEB887Community Feast:|r",
  25.         ["quest71995"] = "|cFFDEB887Trial of the Elements:|r",
  26.         ["yes"] = "|cFF1EFF00Complete|r",
  27.         ["no"] = "|cFFDC143CIncomplete|r"
  28.     }
  29. }
  30. local locale = GetLocale()
  31. local locStrings = localization[locale] or localization["enUS"]
  32.  
  33. local function UpdateDisplay(questID, questStatus)
  34.  
  35.     -- Append newline if questStatus contains information
  36.     if questStatus != "" then
  37.         questStatus .. "\n"
  38.     end
  39.    
  40.     -- Convert questID to a string and create a localization key for it
  41.     questStatus = locStrings["quest" .. tostring(questID)] .. " "
  42.    
  43.     -- Add whether it is completed or not
  44.     if completedQuests[questID] then
  45.         questStatus = questStatus .. locStrings["yes"]
  46.     else
  47.         questStatus = questStatus .. locStrings["no"]
  48.     end
  49.  
  50.     -- Update Text Box
  51.     text:SetText(questStatus)
  52.  
  53.     -- Return the current questStatus contents
  54.     return questStatus
  55.  
  56. end
  57.  
  58. -- Handle what to do when you first log in
  59. local function PlayerLogin(...)
  60.     for _, questID in ipairs(questIDs) do
  61.         local isCompleted = C_QuestLog.IsQuestFlaggedCompleted(questID)
  62.         completedQuests[questID] = isCompleted
  63.     end
  64.    
  65.     -- Statu with an empty questStatus and update it
  66.     local questStatus = ""
  67.     questStatus = UpdateDisplay(70893, questStatus)
  68.     questStatus = UpdateDisplay(71995, questStatus)
  69.  
  70. end
  71.  
  72.  
  73. -- Handle what to do when you turn in a quest
  74. local function QuestTurnedIn(...)
  75.     local questID, xpReward, moneyReward = ...
  76.    
  77.     -- Don't bother continuing if we are not watching this quest
  78.     if questID != 70893 then return end
  79.     if questID != 71995 then return end
  80.    
  81.     local isCompleted = C_QuestLog.IsQuestFlaggedCompleted(questID)   -- Returns true
  82.     completedQuests[questID] = isCompleted
  83.    
  84.     -- Debug Text
  85.     print("Quest: ", questID,"XP: ", xpReward,"Money: ", moneyReward,"Completed: ",isCompleted)
  86.    
  87.     -- Get Current Text Display and Update it
  88.     local questStatus = text:GetText()
  89.     questStatus = UpdateDisplay(questID, questStatus)
  90.  
  91. end
  92.  
  93. -- Handle what to do when you accept a quest
  94. local function QuestAccepted(...)
  95.     local questID = ...
  96.     local questLogIndex = C_QuestLog.GetLogIndexForQuestID(questID)
  97.     local info = { C_QuestLog.GetInfo(questLogIndex) }
  98.    
  99.     -- Add Quest Info to table
  100.     questInfo[questID] = info
  101.    
  102.     -- Debug Text
  103.     print("Accepted Quest: ", questID, info["title"])
  104. end
  105.  
  106. -- Handle events being listened to
  107. frame:SetScript("OnEvent", function(self, event, ...)
  108.     if event == "PLAYER_LOGIN" then
  109.         PlayerLogin(...)
  110.     elseif event == "QUEST_TURNED_IN" then
  111.         -- Triggers when pressing Complete Button
  112.         QuestTurnedIn(...)
  113.     elseif event == "QUEST_ACCEPTED" then
  114.         -- Triggers before Pressing Accept Button
  115.         QuestAccepted(...)
  116.     end
  117. end)
  118.  
  119. frame:RegisterEvent("PLAYER_LOGIN")
  120. frame:RegisterEvent("QUEST_TURNED_IN")
  121. frame:RegisterEvent("QUEST_ACCEPTED")
__________________


Characters:
Gwynedda - 70 - Demon Warlock
Galaviel - 65 - Resto Druid
Gamaliel - 61 - Disc Priest
Gwynytha - 60 - Survival Hunter
Lienae - 60 - Resto Shaman
Plus several others below level 60

Info Panel IDs : http://www.wowinterface.com/forums/s...818#post136818
  Reply With Quote