From 22433ec6c557c7a0fd1d8f965a82854e9f2a5f2e Mon Sep 17 00:00:00 2001 From: "James D. Callahan III" Date: Thu, 14 Oct 2010 01:29:05 -0400 Subject: [PATCH] Re-wrote Player:SetProfession() to work properly for WoW 4.x --- Player.lua | 46 ++++++++++++++++++++++++++++++---------------- 1 file changed, 30 insertions(+), 16 deletions(-) diff --git a/Player.lua b/Player.lua index 3c0e038..ea83378 100644 --- a/Player.lua +++ b/Player.lua @@ -104,25 +104,39 @@ function Player:HasRecipeFaction(recipe) return true end --- Sets the player's professions. Used when the AddOn initializes and when a profession has been learned or unlearned. --- TODO: Make the AddOn actually detect when a profession is learned/unlearned, then call this function. -Torhal -function Player:SetProfessions() - local profession_list = self.professions +do + local known_professions = { + ["prof1"] = false, + ["prof2"] = false, + ["archaeology"] = false, + ["fishing"] = false, + ["cooking"] = false, + ["firstaid"] = false, + } + + -- Sets the player's professions. Used when the AddOn initializes and when a profession has been learned or unlearned. + function Player:SetProfessions() + local profession_list = self.professions + + for i in pairs(profession_list) do + profession_list[i] = false + end + local known = known_professions - for i in pairs(profession_list) do - profession_list[i] = false - end + known.prof1, known.prof2, known.archaeology, known.fishing, known.cooking, known.firstaid = GetProfessions() - for index = 1, 25, 1 do - local spell_name = GetSpellBookItemName(index, BOOKTYPE_SPELL) + for profession, index in pairs(known_professions) do + if index then + local name, icon, rank, maxrank, numspells, spelloffset, skillline = GetProfessionInfo(index) - if not spell_name or index == 25 then - break - end + if name == private.mining_name then + name = private.professions["Smelting"] + end - -- Check for false in the profession_list - a nil entry means we don't care about the spell. - if profession_list[spell_name] == false then - profession_list[spell_name] = true + if profession_list[name] == false then + profession_list[name] = true + end + end end end -end +end -- do-block -- 1.7.9.5