GetSpecialization

From Warcraft Wiki
Jump to navigation Jump to search
Flavors
Links
Info
Added in 5.0.4

Returns the index of the player's current specialization.

currentSpec = GetSpecialization([isInspect, isPet, specGroup])

Arguments

isInspect
boolean? - if true, return information for the inspected player
isPet
boolean? - if true, return information for the player's pet.
specGroup
number? - The index of a given specialization/talent/glyph group (1 for primary / 2 for secondary).

Returns

currentSpec
number - index of the current specialization (ascending from 1), or nil if no specialization is currently learned.

Example

The following snippet prints the name of the player's current specialization if you have one selected.

local currentSpec = GetSpecialization()
if currentSpec then
   local _, currentSpecName = GetSpecializationInfo(currentSpec)
   print("Your current spec:", currentSpecName)
else
   print("You do not currently have a spec.")
end

Details

  • For inspecting another player's spec, see GetInspectSpecialization()
  • Returns a value of 5 as of 9.0.1 for newly created characters.
Related API GetSpecializationInfo
Related Events PLAYER_SPECIALIZATION_CHANGED

Patch changes

Mists of Pandaria Patch 5.0.4 (2012-08-28): Replaced GetPrimaryTalentTree.