Questie

Questie

122M Downloads

When is it safe to call QuestieDB.QueryQuestSingle(questId, "requiredRaces") ?

gouletr opened this issue ยท 2 comments

commented

Question

I am developing an addon which uses Questie as its database for items, quests, npcs, etc. I noticed that sometimes, results returned from the QuestieDB can be invalid (or not ready?).

I have experienced different results when calling this early in my addon:

QuestieDB.QueryQuestSingle(1638, "requiredRaces")

Create a character that is not a warrior, for this specific quest it should always return false, but its not always returning false. I've noticed this generally only happens when opening WoW (cold boot), but not when reloading via /reload.

My gut feeling is that I am using this method too early, but then it raises the question, how does one check if the QuestieDB is ready to be used? I could not find an actual method for this so I made my own:

function MyAddon:IsQuestieInitialized()
    if self.initialized then
        return true
    end

    local initialized =
        QuestieDB ~= nil and
        QuestieDB.QueryNPC ~= nil and type(QuestieDB.QueryNPC) == "function" and
        QuestieDB.QueryQuest ~= nil and type(QuestieDB.QueryQuest) == "function" and
        QuestieDB.QueryObject ~= nil and type(QuestieDB.QueryObject) == "function" and
        QuestieDB.QueryItem ~= nil and type(QuestieDB.QueryItem) == "function" and
        QuestieDB.QueryNPCSingle ~= nil and type(QuestieDB.QueryNPCSingle) == "function" and
        QuestieDB.QueryQuestSingle ~= nil and type(QuestieDB.QueryQuestSingle) == "function" and
        QuestieDB.QueryObjectSingle ~= nil and type(QuestieDB.QueryObjectSingle) == "function" and
        QuestieDB.QueryItemSingle ~= nil and type(QuestieDB.QueryItemSingle) == "function"

    if initialized then
        self.initialized = true
        return true
    end

    return false
end

But its not reliable, otherwise I would not have this issue. Please advise. cc @BreakBB

commented

There is a Questie.started parameter which becomes true once Questie is done loading itself. Give that one a shot.

commented

I have been running with this change for a while and I didn't see the issue again, so yes checking Questie.started looks like its fixing my issue! Thank you very much!