Thread Tools Display Modes
03-06-15, 02:48 PM   #1
Kraiven
A Deviate Faerie Dragon
 
Kraiven's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2015
Posts: 10
spName returning nil instead of spec name

Hey guys, I noticed a small bug in my code that I overlooked before. So basically the highlighted code is suppose to print a chat message telling the player their current "loot spec chosen". When you right click portrait > loot specialization There are 4 options, lets say the warrior for example:
  • Current Specialization (Protection)
    Arms
    Fury
    Protection

When you choose anything other than "Current Specialization" The print works just fine, naming your set loot spec chosen, but if Current Specialization is selected, returns a nil in the chat print.

Question, can anyone point out my obvious mistake? I must have deleted something that I needed before to correct this, unless something changed in 6.1, or I missed an option?

Code:
	local isInstance = IsInInstance()                  -- Check if Player is In an Instance
	if event == "PLAYER_ENTERING_WORLD" and isInstance then  -- "and isInstance" Remove this before 'then' to test code without being in LFG instance  
		local currentSpec = GetSpecialization()
		local currentSpecName = currentSpec and select(2, GetSpecializationInfo(currentSpec)) or "None" -- Get Current Spec Name
		local role = UnitGroupRolesAssigned("player"); -- Role selected or assigned in LFG 
		local spec = GetSpecialization()
		local specRole = GetSpecializationRole(spec)   -- Current Role Specialization
		if role ~= specRole then
			local specId = GetSpecialization() 		   -- Loot Role Info
			local spId = GetLootSpecialization()   	   -- Loot Role Info
			local sId, spName = GetSpecializationInfoByID(spId) -- Loot Role Info
			StaticPopup_Show ("WRONG_SPEC_WARNING")    -- Show Static PopUp from below
			playSound()								   -- Illidan Sound File
			print("|cffffff00--- SpecCheck Addon Warning: Wrong Role Active")
			print("|cff00ccff--- Active Specialization:|r ", currentSpecName)
			print("|cff00ccff--- Loot Specialization: |r", spName)
Thanks for any help and taking the time to look,
Krai
  Reply With Quote
03-06-15, 04:10 PM   #2
Lombra
A Molten Giant
 
Lombra's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 554
GetLootSpecialization() returns 0 if you set it to "current spec". It doesn't actually return the ID of your current spec.
__________________
Grab your sword and fight the Horde!
  Reply With Quote
03-07-15, 06:36 PM   #3
Kraiven
A Deviate Faerie Dragon
 
Kraiven's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2015
Posts: 10
Arrow another question

Thank you, I ended up finding a work around by basically printing the currentSpecName in place of the lootSpecName if the return was 0. Cheap fix but it works for now.

One thing I noticed about my addon is that it cannot tell the different between a LFG/LFR Instance or if I was to walk into my own raid zone. I've tried a few variations of the code below, but I'm not sure if I'm pointing it towards the right place, or maybe there's a better api function to get my results. Any thoughts or pointers? I'd like to only have my addon fire when the player is in LFR/LFG instances. Thanks again.

Code:
mode = GetLFGMode()
if mode == nil then
	-- do nothing
else
	-- do my addon stuff
Sorry for so many questions, but I'm learning by doing and when I get stumped I try and reach out to the experts.
  Reply With Quote
03-08-15, 07:52 AM   #4
Talyrius
An Onyxian Warder
 
Talyrius's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 363
Code:
if IsInGroup(LE_PARTY_CATEGORY_INSTANCE) then
	-- in an instance group
elseif IsInGroup() then
	-- in a normal group
end
  Reply With Quote
03-08-15, 04:10 PM   #5
Kraiven
A Deviate Faerie Dragon
 
Kraiven's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2015
Posts: 10
Thank you, I didn't see that function before, and it worked.
  Reply With Quote
03-10-15, 03:15 PM   #6
Kraiven
A Deviate Faerie Dragon
 
Kraiven's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2015
Posts: 10
Thank you that worked, but of course I ran into another problem. For some reason the addon fires in the proving grounds for no reason. I'm assuming its based under a scenario type, but the api listed does not return the correct info:

name, type, difficulty, difficultyName, maxPlayers, playerDifficulty, isDynamicInstance, mapID, instanceGroupSize = GetInstanceInfo()

I tried using many different variations and even instanceType but still can't tell if the player is is the proving grounds or not. Can't find any info on proving grounds being "not" a scenario so I have to assume this should work.
Code:
if event == "PLAYER_ENTERING_WORLD" and isInstance then 
	local inInstanceGroup = IsInGroup(LE_PARTY_CATEGORY_INSTANCE)
	local name, type, difficulty, difficultyName, maxPlayers, playerDifficulty, isDynamicInstance, mapID, instanceGroupSize = GetInstanceInfo()
	if inInstanceGroup and type ~= scenario then
   -- do my code but only if not in a scenario
  Reply With Quote
03-10-15, 09:54 PM   #7
Talyrius
An Onyxian Warder
 
Talyrius's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 363
The instance type returned from GetInstanceInfo is a string. You forgot the quotation marks.
  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » spName returning nil instead of spec name

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off