Search code examples
luaworld-of-warcraft

Issue with C_TaskQuest.GetQuestInfoByQuestID(questID)


I'm practicing making an addon for World of Warcraft. I'm trying to display quest titles by retrieving the information from Wow's API and displaying in a frame. I can display if the quest has been completed or not just fine, but when I attempt to use the C_TaskQuest.GetQuestInfoByQuestID(questID) endpoint; nothing gets printed to the screen.

local function questStatus()
    for questID = 1, #array do
        local y = topY - (questID * 15 - 20)
        local fontString = UIConfig:CreateFontString(nil, "ARTWORK")
        fontString:SetFont("Fonts\\ARIALN.ttf", 13, "OUTLINE")
            fontString:SetText(C_TaskQuest.GetQuestInfoByQuestID(array[questID]))
            fontString:SetPoint("TOPLEFT", topX, y)
    end
end

the error I get in the chat frame is

7x Usage: local questTitle, factionID, capped, displayAsObjective = C_TaskQuest.GetQuestInfoByQuestID(questID)
[string "=[C]:"]: in function 'GetQuestInfoByQuestID'
[string "@My-Addon\Core.lua"]:66: in main chunk

Any help is appreciated, thanks!


Solution

  • C_TaskQuest.GetQuestInfoByQuestID() only returns proper values for world quests but you can use C_QuestLog.GetQuestInfo() instead. Note that the data still has to be cached, the first time it won't be available until the QUEST_LOG_UPDATE event

    See https://www.townlong-yak.com/framexml/go/QuestUtils_GetQuestName