Navigation menu
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
Namespaces
WoW
Talk
English
Views
Read
Edit
History
More
Search
Navigation
Home
Random page
Help using wiki
Editions
for WoW
for WildStar
for Solar2D
Documentation
for WoW
for WildStar
Reference
WoW
⦁ FrameXML
⦁ AddOns
⦁ API
⦁ WoW Lua
WildStar
⦁ AddOns
⦁ API
⦁ WildStar Lua
Engine
Tools
What links here
Related changes
Special pages
Page information
Site
Recent Changes
Editing
WoW:Earth (AddOn)/Using earth to create a QuestLog
(section)
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== Parsing the Player's Quest List == The next step is to create a table which contains all of the Quests a player has. This part is kind of complicated, but I am probably going to commit my function to [[Sea (AddOn)|Sea]], so you don't have to worry about the details too much. First thing, write the function to get all of the information from the game. -- Generates the current player's quest list -- function PartyQuests_GetPlayerQuestTree() -- Expand everything ExpandQuestHeader(0); -- Build our quest list local numEntries, numQuests = GetNumQuestLogEntries(); local questList = {}; local activeTable = nil; for i=1, PARTYQUESTS_QUESTS_DISPLAYED, 1 do local questIndex = i; if ( questIndex <= numEntries ) then local title, level, questTag, isHeader, isCollapsed, isComplete = GetQuestLogTitle(questIndex); local color; if ( title ) then if ( isHeader ) then questList[title] = {}; activeTable = questList[title]; else if ( activeTable == nil ) then activeTable = questList; end local entry = {}; entry.title = title; entry.level = level; entry.tag = questTag; entry.complete = isComplete; table.insert(activeTable, entry); end end end end return questList; end Everything looks great, right? Uh oh! Whats this? We had to call [[API_ExpandQuestHeader|ExpandQuestHeader]] to ensure we got all of the quests. This means the player's collapsed quests will be expanded. He won't like that, so first thing we do is create a function to keep track of all of his collapsed quests and a function to re-collapse them when done. We also want to make sure no other function tries call us for an update while we're still parsing the information. (For you advanced programmers, I'm making sure my code is thread-safe). We add a bit called "PartyQuests_CurrentlyGettingQuestData" to ensure we can't call this funcion before it is finished. -- Generates the current player's quest list -- function PartyQuests_GetPlayerQuestTree() if ( PartyQuests_CurrentlyGettingQuestData ) then return true; end PartyQuests_CurrentlyGettingQuestData = true; -- Store the collapsed local collapsed = PartyQuests_StoreCollapsedQuests(); -- Expand everything ExpandQuestHeader(0); -- Build our quest list local numEntries, numQuests = GetNumQuestLogEntries(); <SNIP> -- Collapse again PartyQuests_CollapseStoredQuests(collapsed); -- Unlock the thread PartyQuests_CurrentlyGettingQuestData = false; return questList; end Whew! Okay. Next we implement those two quick functions: -- Stores the currently collapsed quests -- function PartyQuests_StoreCollapsedQuests() local collapsed = {}; for i=1, PARTYQUESTS_QUESTS_DISPLAYED, 1 do local title, level, questTag, isHeader, isCollapsed, isComplete = GetQuestLogTitle(i); if ( isCollapsed ) then table.insert(collapsed, title); end end return collapsed; end -- Collapse the quests we stored -- function PartyQuests_CollapseStoredQuests(collapseThese) for i=1, PARTYQUESTS_QUESTS_DISPLAYED, 1 do local title, level, questTag, isHeader, isCollapsed, isComplete = GetQuestLogTitle(i); if ( Sea.list.isInList(collapseThese, title) ) then CollapseQuestHeader(i); end end end * Author's Note: I've now added more advanced versions of these two functions to [[Sea (AddOn)|Sea]]. ** Check out [[Sea.wow.questLog.protectQuestLog]]() and [[Sea.wow.questLog.unprotectQuestLog]]().
Summary:
Please note that all contributions to AddOn Studio are considered to be released under the Creative Commons Attribution-NonCommercial-ShareAlike (see
AddOn Studio Wiki:Copyrights
for details).
Submissions must be written by you, or copied from a public domain or similar free resource (see
AddOn Studio Wiki:Copyrights
for details).
Cancel
Editing help
(opens in new window)