Did you check to make sure that the event triggered when you clicked on the complete button for the quest ?
It is also possible that the IsQuestFlaggedCompleted function doesn't know about the just completed quest yet. If that is the case, the only thing you can do is use the OnUpdate function and put a timed check in there to periodically check if it is marked as complete yet.
Let me check with one of my test toons and see if a simple test works as I expect it to.
Okay.. I just tested with this small piece of code.
Lua Code:
local addonName, addonNS = ...
Quests_Completed = Quests_Completed or {}
local function QuestTurnedIn(...)
local questID, xpReward, moneyReward = ...
local isCompleted = C_QuestLog.IsQuestFlaggedCompleted(questID) -- Returns true
print("Quest: ", questID,"XP: ", xpReward,"Money: ", moneyReward,"Completed: ",isCompleted)
Quests_Completed[questID].Completed = isCompleted
end
local function QuestAccepted(...)
local questID = ...
local questLogIndex = C_QuestLog.GetLogIndexForQuestID(questID)
local info = { C_QuestLog.GetInfo(questLogIndex) }
print("Accepted Quest: ", questID, info["title"])
Quests_Completed[questID] = info
end
local frame = CreateFrame("Frame")
frame:RegisterEvent("QUEST_TURNED_IN")
frame:RegisterEvent("QUEST_ACCEPTED")
frame:SetScript("OnEvent", function(self, event, ...)
if event == "QUEST_TURNED_IN" then
-- Triggers when pressing Complete Button
QuestTurnedIn(...)
elseif event == "QUEST_ACCEPTED" then
-- Triggers before Pressing Accept Button
QuestAccepted(...)
end
end)
It worked as expected with the addon recognising that a quest had been turned in as it was turned in and marked it as completed immediately. The only slight error on my part was trying to display info.title instead of info["title"] on the screen.
It might be that the quests you are looking into in particular are working differently. Try separating the event tests and see whether the QUEST_TURNED_IN functionality kicks in correctly.
The saved variables show that on QUEST_ACCEPTED all of the information was available and on QUEST_TURNED_IN it knew it had been completed. In this example, the first alliance human quest was completed with the second accepted but not completed.
Lua Code:
Quests_Completed = {
[28757] = {
{
["difficultyLevel"] = 1,
["useMinimalHeader"] = false,
["isHeader"] = false,
["questLogIndex"] = 2,
["level"] = 1,
["isOnMap"] = false,
["isTask"] = false,
["isHidden"] = false,
["overridesSortOrder"] = false,
["isInternalOnly"] = false,
["isCollapsed"] = true,
["startEvent"] = false,
["questID"] = 28757,
["suggestedGroup"] = 0,
["isBounty"] = false,
["readyForTranslation"] = true,
["isLegendarySort"] = false,
["title"] = "Beating Them Back!",
["isAutoComplete"] = false,
["isStory"] = false,
["hasLocalPOI"] = false,
["isScaling"] = true,
["frequency"] = 0,
}, -- [1]
["Completed"] = true,
},
[28769] = {
{
["difficultyLevel"] = 2,
["useMinimalHeader"] = false,
["isHeader"] = false,
["questLogIndex"] = 2,
["level"] = 2,
["isOnMap"] = false,
["isTask"] = false,
["isHidden"] = false,
["overridesSortOrder"] = false,
["isInternalOnly"] = false,
["isCollapsed"] = true,
["startEvent"] = false,
["questID"] = 28769,
["suggestedGroup"] = 0,
["isBounty"] = false,
["readyForTranslation"] = true,
["isLegendarySort"] = false,
["title"] = "Lions for Lambs",
["isAutoComplete"] = false,
["isStory"] = false,
["hasLocalPOI"] = false,
["isScaling"] = true,
["frequency"] = 0,
}, -- [1]
},
}