LibPvpTalents
LibPvpTalents is a library that makes working with the PvP talent API easier. The library will automatically detect the player's level, which pvp talent slots are available, and which pvp talents can be selected, and exposes an API that makes it easy to retrieve information about the available and selected pvp talents and setting pvp talents programmatically. The library can both be used as a standalone addon (which can be installed through the Twitch client) that exposes a global LibPvpTalents variable (good for quick testing), and as a LibStub library.
Setup - Standalone addon
To use this library as a standalone addon, simply install it through the Twitch client, or extract the zip file directly into WoW\_retail_\Interface\Addons and activate the addon in the game client. The addon will expose a global LibPvpTalents variable that can be used from anywhere.
Setup - Libstub library
Download and extract the latest zip file found in the 'files' tab, and copy only the LibPvpTalents.lua file, and optionally the LibStub folder if you don't have LibStub included in your project yet.
Ensure you have a reference to LibStub.lua either from your .toc file or a .xml file, and ensure LibPvpTalents.lua is referenced after LibStub for the correct load order. The other files included in the zip are only needed for running the library as a standalone addon and as such can be left out when using the library in LibStub mode.
To use the LibPvpTalents library as a LibStub library, you'd load it like this in your main addon: local LibPvpTalents = LibStub:GetLibrary("LibPvpTalents-1.0");
API docs
PvpTalent object
All functions that return talents or a list of talents will return the talents in the following table format, for easy lookup of data:
- number talentID,
- string name,
- number/fileID texture,
- boolean selected,
- boolean available,
- number spellID,
- boolean unlocked,
- number row (always 1 for pvp talents),
- number column (always 1 for pvp talents),
- boolean known,
- boolean grantedByAura
LibPvpTalents:GetAllTalents()
Returns a list of all PvP talents, even if they're not unlocked and cannot be selected by the player yet.
LibPvpTalents:GetAvailableTalents()
Returns a list of all available/unlocked PvP talents, that can be selected by the player.
LibPvpTalents:GetTalentByID(talentID)
Accepts: a number talentID, referring to the talent's internal ID.
Returns: a talent, or nil.
LibPvpTalents:GetTalentBySpellID(spellID)
Accepts: a number spellID, referring to the ID of the spell that the talent grants.
Returns: a talent, or nil.
LibPvpTalents:GetTalentByName(name)
Accepts: a string name, which is the talent's name.
Returns: a talent, or nil.
LibPvpTalents:GetAvailableTalentByID(talentID)
Accepts: a number talentID, referring to the talent's internal ID.
Returns: a talent, or nil. Will only look through the available talents that can be selected by the player.
LibPvpTalents:GetAvailableTalentBySpellID(spellID)
Accepts: a number spellID, referring to the ID of the spell that the talent grants.
Returns: a talent, or nil. Will only look through the available talents that can be selected by the player.
LibPvpTalents:GetAvailableTalentByName(name)
Accepts: a string name, which is the talent's name.
Returns: a talent, or nil. Will only look through the available talents that can be selected by the player.
LibPvpTalents:IsTalentSelected(talentID)
Accepts: a number talentID, referring to the talent's internal ID.
Returns: a boolean indicating whether the player has selected this talent or not.
LibPvpTalents:IsTalentSelectedBySpellID(spellID)
Accepts: a number spellID, referring to the ID of the spell that the talent grants.
Returns: a boolean indicating whether the player has selected this talent or not.
LibPvpTalents:IsTalentSelectedByName(name)
Accepts: a string name, which is the talent's name.
Returns: a boolean indicating whether the player has selected this talent or not.
LibPvpTalents:TalentCanBeSelected(talent)
Accepts: either a talent object, a number talent ID referring to the talent's internal ID, or a string name, which is the talent's name.
Returns: a boolean indicating whether the player can select this talent or not. In case of failure, defaults to false.
LibPvpTalents:TalentCanBeSelectedBySpellID(spellID)
Accepts: a number spellID, referring to the ID of the spell that the talent grants.
Returns: a boolean indicating whether the player can select this talent or not. In case of failure, defaults to false.
LibPvpTalents:GetAvailableSlotAmount()
Returns: a number indicating the amount of PvP talent slots the player has unlocked.
LibPvpTalents:SlotIsAvailable(slotID)
Accepts: a number slotID, referring to the slot number. Either 1, 2 or 3.
Returns: a boolean indicating whether the selected slot has been unlocked and can be assigned to.
LibPvpTalents:SlotIsEmpty(slotID)
Accepts: a number slotID, referring to the slot number. Either 1, 2 or 3.
Returns: a boolean, true if the selected Slot has been unlocked but has not been assigned a PvP talent, false otherwise.
LibPvpTalents:GetTalentBySlotID(slotID)
Accepts: a number slotID, referring to the slot number. Either 1, 2 or 3.
Returns: a table object, or nil.
LibPvpTalents:SetPvpTalent(talent, slotID)
Accepts:
1. either a talent object, a number talent ID referring to the talent's internal ID, or a string name, which is the talent's name.
2. a number slotID, referring to the slot number to assign the talent to.
Returns: a boolean indicating whether the talent was set successfully or not.
LibPvpTalents:SetPvpTalentBySpellID(spellID, slotID)
Accepts:
1. a number spellID, referring to the ID of the spell that the talent grants.
2. a number slotID, referring to the slot number to assign the talent to.
Returns: a boolean indicating whether the talent was set successfully or not.