0% found this document useful (0 votes)
7 views9 pages

API

Uploaded by

yonier parque
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views9 pages

API

Uploaded by

yonier parque
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 9

--------------------------------------------------------------------------

--
-- LibClassicInspector by kebabstorm
-- for Classic/TBC/WOTLK
--
-- API Version 9 (2022-12-11)
--
--------------------------------------------------------------------------

--------------------------------------------------------------------------
--
-- LIBRARY CALLBACKS
--
--------------------------------------------------------------------------

--------------------------------------------------------------------------
-- ClassicInspector.RegisterCallback(addOnName, "INVENTORY_READY",
inventoryReadyCallback)
-- ClassicInspector.RegisterCallback(addOnName, "TALENTS_READY",
talentsReadyCallback)
-- ClassicInspector.RegisterCallback(addOnName, "ACHIEVEMENTS_READY",
achievementsReadyCallback)
-- ClassicInspector.RegisterCallback(addOnName, "GLYPHS_READY",
glyphsReadyCallback)
--
-- Note
-- The callbacks are useful if you need to present data the instant it becomes
available,
-- but in most cases these aren't needed and using the data request functions
is enough.
--
-- Parameters
-- @string addOnName - your addon unique name
-- @string event - event name (e.g. "INVENTORY_READY")
-- @function callbackFunc - your callback function
--
-- Returns
-- @string event - event name
-- @string guid - player guid
-- @boolean isInspect - was the result of inspection
-- @string [unit] - unit token (optional, can return nil if not
available)
--
local function inventoryReadyCallback(event, guid, isInspect, unit)
local function talentsReadyCallback(event, guid, isInspect, unit)
local function achievementsReadyCallback(event, guid, isInspect, unit)
local function glyphsReadyCallback(event, guid, isInspect, unit)

--------------------------------------------------------------------------
--
-- LIBRARY FUNCTIONS
--
--------------------------------------------------------------------------

--------------------------------------------------------------------------
-- ClassicInspector:GetSpecializationName(class, tabIndex, localized)
--
-- Parameters
-- @string class - english class name in uppercase e.g. "WARRIOR"
-- @number tabIndex - talent tab index (1-3)
-- @boolean localized - return localized name instead of english name
--
-- Returns
-- @string specName - specialization name e.g. "Retribution"
--
function lib:GetSpecializationName(class, tabIndex)
return specName

--------------------------------------------------------------------------
-- ClassicInspector:GetNumTalentsByClass(class, tabIndex)
--
-- Parameters
-- @string class - english class name in uppercase e.g. "WARRIOR"
-- @number tabIndex - talent tab index (1-3)
--
-- Returns
-- @number numTalents - number of talents in tab
--
function lib:GetNumTalentsByClass(class, tabIndex)
return numTalents

--------------------------------------------------------------------------
-- ClassicInspector:GetSpecialization(unitorguid[, group])
--
-- Parameters
-- @string unitorguid - unit token or guid
-- @number [group] - talent group or the current active talent
group if nil
--
-- Returns
-- @number specIndex - main specialization index (1-3)
-- @number pointsSpent - talent points spent to the main spec
--
function lib:GetSpecialization(unitorguid, _group)
return specIndex, mostPoints

--------------------------------------------------------------------------
-- ClassicInspector:GetTalentPoints(unitorguid[, group])
--
-- Parameters
-- @string unitorguid - unit token or guid
-- @number [group] - talent group or the current active talent
group if nil
--
-- Returns
-- @number pointsSpent1 - talent points spent to tab 1
-- @number pointsSpent2 - talent points spent to tab 2
-- @number pointsSpent3 - talent points spent to tab 3
--
function lib:GetTalentPoints(unitorguid, _group)
return pointsSpent1, pointsSpent2, pointsSpent3

--------------------------------------------------------------------------
-- ClassicInspector:GetActiveTalentGroup(unitorguid)
--
-- Parameters
-- @string unitorguid - unit token or guid
--
-- Returns
-- @number group - active talent group (1-2)
--
function lib:GetActiveTalentGroup(unitorguid)
return group

--------------------------------------------------------------------------
-- ClassicInspector:GetTalentInfo(unitorguid, tabIndex, talentIndex[, group])
--
-- Note
-- talentID is currently unimplemented and returns 0
--
-- Parameters
-- @string unitorguid - unit token or guid
-- @number tabIndex - talent tab index (1-3)
-- @number talentIndex - ranging from 1 to GetNumTalents(tabIndex).
counted from left to right, top to bottom.
-- @number [group] - talent group or the current active talent
group if nil
--
-- Returns
-- @string name - name of the talent
-- @number iconTexture - fileID of icon texture
-- @number tier - the row/tier that the talent sits on
-- @number column - the column that the talent sits on
-- @number rank - the current amount of talent points for a
talent
-- @number maxRank - the maximum amount of talent points for a
talent
-- @number isExceptional - 1 if the talent is the ultimate talent, e.g.
Lightwell, otherwise returns nil
-- @number available - always 1
-- @number talentID - talent ID
--
function lib:GetTalentInfo(unitorguid, tabIndex, talentIndex, _group)
return name, iconTexture, tier, column, rank, maxRank, isExceptional,
available, id

--------------------------------------------------------------------------
-- ClassicInspector:GetTalentInfoByClass(class, tabIndex, talentIndex)
--
-- Note
-- talentID is currently unimplemented and returns 0
--
-- Parameters
-- @string class - english class name in uppercase e.g. "WARRIOR"
-- @number tabIndex - talent tab index (1-3)
-- @number talentIndex - ranging from 1 to GetNumTalents(tabIndex).
counted from left to right, top to bottom.
--
-- Returns
-- @string name - name of the talent
-- @number iconTexture - fileID of icon texture
-- @number tier - the row/tier that the talent sits on
-- @number column - the column that the talent sits on
-- @number rank - always 0
-- @number maxRank - the maximum amount of talent points for a
talent
-- @number isExceptional - 1 if the talent is the ultimate talent, e.g.
Lightwell, otherwise returns nil
-- @number available - always 1
-- @number talentID - talent ID
--
function lib:GetTalentInfoByClass(class, tabIndex, talentIndex)
return name, texture, tier, column, 0, maxRank, isExceptional, available, id

--------------------------------------------------------------------------
-- ClassicInspector:GetInventoryItemID(unitorguid, slot)
--
-- Parameters
-- @string unitorguid - unit token or guid
-- @number inventorySlot - inventory slot (1-19)
--
-- Returns
-- @number itemID - inventory item id
--
function lib:GetInventoryItemID(unitorguid, slot)
return itemID

--------------------------------------------------------------------------
-- ClassicInspector:GetInventoryItemLink(unitorguid, slot)
--
-- Parameters
-- @string unitorguid - unit token or guid
-- @number inventorySlot - inventory slot (1-19)
--
-- Returns
-- @string itemLink - inventory item link (can return nil if item is
not cached yet)
--
function lib:GetInventoryItemLink(unitorguid, slot)
return itemLink

--------------------------------------------------------------------------
-- ClassicInspector:GetInventoryItemMixin(unitorguid, slot)
--
-- Parameters
-- @string unitorguid - unit token or guid
-- @number inventorySlot - inventory slot (1-19)
--
-- Returns
-- @ItemMixin item - inventory item ItemMixin
--
function lib:GetInventoryItemMixin(unitorguid, slot)
return item

--------------------------------------------------------------------------
-- ClassicInspector:GetInventoryItemIDTable(unitorguid)
--
-- Parameters
-- @string unitorguid - unit token or guid
--
-- Returns
-- @table inventoryTable - inventory item id table (1-19)
--
function lib:GetInventoryItemIDTable(unitorguid)
return inventoryTable
--------------------------------------------------------------------------
-- ClassicInspector:GetTalentRanksTable(unitorguid)
--
-- Parameters
-- @string unitorguid - unit token or guid
--
-- Returns
-- @table talentsTable - talent ranks table
--
function lib:GetTalentRanksTable(unitorguid)
return talentsTable

--------------------------------------------------------------------------
-- ClassicInspector:GetLastCacheTime(unitorguid)
--
-- Parameters
-- @string unitorguid - unit token or guid
--
-- Returns
-- @number talentsTime - time when talents were last cached or 0 if not
found
-- @number inventoryTime - time when inventory was last cached or 0 if
not found
-- @number achievementsTime - time when achievements were last cached or 0
if not found
-- @number glyphsTime - time when glyphs were last cached or 0 if not
found
--
function lib:GetLastCacheTime(unitorguid)
return talentsTime, inventoryTime, achievementsTime, glyphsTime

--------------------------------------------------------------------------
-- ClassicInspector:PlayerGUIDToUnitToken(unit)
--
-- Parameters
-- @string guid - player guid
--
-- Returns
-- @string unit - player unit token
--
function lib:PlayerGUIDToUnitToken(guid)
return unit

--------------------------------------------------------------------------
-- ClassicInspector:IsClassic()
--
-- Returns
-- @boolean isClassic - client version is Classic "Vanilla": Means
Classic Era and its seasons like SoM (1.x.x)
--
function lib:IsClassic()
return isClassic

--------------------------------------------------------------------------
-- ClassicInspector:IsTBC()
--
-- Returns
-- @boolean isTBC - client version is Classic TBC (2.x.x)
--
function lib:IsTBC()
return isTBC

--------------------------------------------------------------------------
-- ClassicInspector:IsWotlk()
--
-- Returns
-- @boolean isWotlk - client version is Classic Wotlk (3.x.x)
--
function lib:IsWotlk()
return isWotlk

--------------------------------------------------------------------------
-- ClassicInspector:CanInspect(unitorguid)
--
-- Note
-- This function is provided for special cases and does not need to be used in
normal operation.
-- Inspections are handled automatically by the library and do not need to be
handled manually.
--
-- Parameters
-- @string unitorguid - unit token or guid of target to check
--
-- Returns
-- @boolean canInspect - can target unit be inspected
--
function lib:CanInspect(unitorguid)
return canInspect

--------------------------------------------------------------------------
-- ClassicInspector:DoInspect(unitorguid)
--
-- Note
-- This function is provided for special cases and does not need to be used in
normal operation.
-- Inspections are handled automatically by the library and do not need to be
handled manually.
--
-- Parameters
-- @string unitorguid - unit token or guid of inspection target
--
-- Returns
-- @number status - inspection status
-- == 0 : target cannot be inspected
-- == 1 : instant inspection
-- == 2 : queued inspection
--
function lib:DoInspect(unitorguid)
return status

--------------------------------------------------------------------------
-- ClassicInspector:Version()
--
-- Returns
-- @number version - library version
--
function lib:Version()
return version
--------------------------------------------------------------------------
-- [WOTLK]
-- ClassicInspector:GetTotalAchievementPoints(unitorguid)
--
-- Parameters
-- @string unitorguid - unit token or guid
--
-- Returns
-- @number total_points - total achievement points
--
function lib:GetTotalAchievementPoints(unitorguid)
return total_points

--------------------------------------------------------------------------
-- [WOTLK]
-- ClassicInspector:GetAchievementInfo(unitorguid, achievementID)
--
-- Parameters
-- @string unitorguid - unit token or guid
-- @number achievementID - achievement ID (type=achievement)
--
-- Returns
-- @boolean completed - is achievement completed
-- @number month - month of completion
-- @number day - day of completion
-- @number year - year of completion
--
function lib:GetAchievementInfo(unitorguid, achievementID)
return completed, month, day, year

--------------------------------------------------------------------------
-- [WOTLK]
-- ClassicInspector:GetStatistic(unitorguid, achievementID)
--
-- Parameters
-- @string unitorguid - unit token or guid
-- @number achievementID - achievement ID (type=statistic)
--
-- Returns
-- @string value - value of the statistic as displayed in-game
--
function lib:GetStatistic(unitorguid, achievementID)
return value

--------------------------------------------------------------------------
-- [WOTLK]
-- ClassicInspector:AddTrackedAchievement(achievementID)
--
-- Note
-- It is not required to use this, as using the GetAchievementInfo/GetStatistic
functions
-- will automatically add the requested achievement to the tracking list.
--
-- Parameters
-- @number achievementID - achievement ID (type=achievement/statistic)
--
-- Returns
-- @boolean success - achievementID is valid and added to tracking
list
-- @boolean isStatistic - is achievement type a statistic
--
function lib:AddTrackedAchievement(achievementID)
return success, isStatistic

--------------------------------------------------------------------------
-- [WOTLK]
-- ClassicInspector:GetGlyphSocketInfo(unitorguid, socketID[, group])
--
-- Note
-- iconFile is currently implemented only for the local player and returns 0
when requesting
-- info for other players
--
-- Parameters
-- @string unitorguid - unit token or guid
-- @number socketID - socket index to query, ranging from 1 to 6
(NUM_GLYPH_SLOTS)
-- @number [group] - talent group or the current active talent
group if nil
--
-- Returns
-- @boolean enabled - true if the socket has a glyph inserted
-- @number glyphType - type of glyph accepted by this socket
(GLYPHTYPE_MAJOR=1 or GLYPHTYPE_MINOR=2)
-- @number glyphSpellID - spell ID of the socketed glyph
-- @number iconFile - file ID of the sigil icon associated with the
socketed glyph
--
function lib:GetGlyphSocketInfo(unitorguid, socketID, _group)
return enabled, glyphType, glyphSpellID, iconFile

--------------------------------------------------------------------------
-- [WOTLK]
-- ClassicInspector:HasGlyph(unitorguid, glyphSpellID[, group])
--
-- Parameters
-- @string unitorguid - unit token or guid
-- @number glyphSpellID - spell ID of the socketed glyph
-- @number [group] - talent group or the current active talent
group if nil
--
-- Returns
-- @boolean enabled - true if the player has socketed glyph with
matching ID
--
function lib:HasGlyph(unitorguid, glyphSpellID, _group)
return enabled

--------------------------------------------------------------------------
-- [WOTLK]
-- ClassicInspector:GetGlyphs(unitorguid[, group])
--
-- Parameters
-- @string unitorguid - unit token or guid
-- @number [group] - talent group or the current active talent
group if nil
--
-- Returns
-- @number glyphSpellID1 - spell ID of glyph in socket 1 (MAJOR)
-- @number glyphSpellID2 - spell ID of glyph in socket 2 (MINOR)
-- @number glyphSpellID3 - spell ID of glyph in socket 3 (MINOR)
-- @number glyphSpellID4 - spell ID of glyph in socket 4 (MAJOR)
-- @number glyphSpellID5 - spell ID of glyph in socket 5 (MINOR)
-- @number glyphSpellID6 - spell ID of glyph in socket 6 (MAJOR)
--
function lib:GetGlyphs(unitorguid, _group)
return glyphSpellID1, glyphSpellID2, glyphSpellID3, glyphSpellID4,
glyphSpellID5, glyphSpellID6

You might also like