Hi all. Currently, the data on
questIDs = {70893, 71995} is updated only after an “interface reboot” or if I re-enter the game as a character. How to make the data updated immediately without having to enter “/reload”. ?
Lua Code:
local addonName, addon = ...
local frame = CreateFrame("Frame", "QuestCompletionFrame", UIParent)
frame:SetSize(100, 100)
frame:SetPoint("CENTER")
frame:EnableMouse(true)
frame:SetMovable(true)
frame:RegisterForDrag("LeftButton")
frame:SetScript("OnDragStart", frame.StartMoving)
frame:SetScript("OnDragStop", frame.StopMovingOrSizing)
local text = frame:CreateFontString(nil, "OVERLAY", "GameFontNormal")
text:SetPoint("CENTER")
local localization = {
["enUS"] = {
["quest70893"] = "|cFFDEB887Community Feast:|r",
["quest71995"] = "|cFFDEB887Trial of the Elements:|r",
["yes"] = "|cFF1EFF00Complete|r",
["no"] = "|cFFDC143CIncomplete|r"
}
}
local function UpdateQuestCompletion()
local completedQuests = {}
local questIDs = {70893, 71995}
for _, questID in ipairs(questIDs) do
local isCompleted = C_QuestLog.IsQuestFlaggedCompleted(questID)
completedQuests[questID] = isCompleted
end
local locale = GetLocale()
local locStrings = localization[locale] or localization["enUS"]
local questStatus = locStrings["quest70893"] .. " "
if completedQuests[70893] then
questStatus = questStatus .. locStrings["yes"]
else
questStatus = questStatus .. locStrings["no"]
end
questStatus = questStatus .. "\n" .. locStrings["quest71995"] .. " "
if completedQuests[71995] then
questStatus = questStatus .. locStrings["yes"]
else
questStatus = questStatus .. locStrings["no"]
end
text:SetText(questStatus)
end
frame:SetScript("OnEvent", function(self, event, ...)
if event == "PLAYER_LOGIN" then
UpdateQuestCompletion()
end
end)
frame:RegisterEvent("PLAYER_LOGIN")
SLASH_ZAM1 = "/zam"
SlashCmdList["ZAM"] = function(msg)
if strupper(strtrim(msg)) == "MT" then -- toggle the shown state of the button if the type /hubb btn
QuestCompletionFrame:SetShown(not QuestCompletionFrame:IsShown()) -- show the button
return
end
updateData()
updateList()
QuestCompletionFrame:Show()
end