WoW:API GetCompanionInfo: Difference between revisions

From AddOn Studio
Jump to navigation Jump to search
(Clarify spell ID return value)
(add known issue)
Line 23: Line 23:
:;icon: String - The texture of the icon for the companion.
:;icon: String - The texture of the icon for the companion.
:;issummoned: integer - 1 if the companion is summoned, nil if it's not
:;issummoned: integer - 1 if the companion is summoned, nil if it's not
== Known Issues ==
If called early in the loading process, before [[Events/Companion|COMPANION_UPDATE]] fires, GetCompanionInfo returns companions in the order that they were learned by the current character.  After COMPANION_UPDATE has fired at least once, GetCompanionInfo returns companions in alphabetical order.  This information is accurate as of WoW 3.1.2.


== Example ==
== Example ==
Line 39: Line 43:
  7553 Great Horned Owl 10707 Interface\Icons\Ability_EyeOfTheOwl nil  
  7553 Great Horned Owl 10707 Interface\Icons\Ability_EyeOfTheOwl nil  
<!-- end code -->
<!-- end code -->
[[Category:World of Warcraft API]]
[[Category:World of Warcraft API]]

Revision as of 10:00, 20 May 2009

WoW API < GetCompanionInfo


Returns information about the companions you have. New in Patch 3.0

creatureID, creatureName, creatureSpellID, icon, issummoned = GetCompanionInfo("type", id)

Parameters

Arguments

("type")
type
String - The TypeID to query (e.g. "CRITTER", or "MOUNT")
id
Integer - The slot id to query (starts at 1).

Returns

creatureID
Integer - The NPC ID of the companion.
creatureName
String - The name of the companion.
creatureSpellID
Integer - The spell ID to cast the companion. This is not passed to CallCompanion, but can be used with, e.g., GetSpellInfo.
icon
String - The texture of the icon for the companion.
issummoned
integer - 1 if the companion is summoned, nil if it's not

Known Issues

If called early in the loading process, before COMPANION_UPDATE fires, GetCompanionInfo returns companions in the order that they were learned by the current character. After COMPANION_UPDATE has fired at least once, GetCompanionInfo returns companions in alphabetical order. This information is accurate as of WoW 3.1.2.

Example

for i=1,GetNumCompanions("CRITTER"),1 do
local creatureID, creatureName, creatureSpellID, icon, issummoned = GetCompanionInfo("CRITTER", i);
ChatFrame1:AddMessage(creatureID .. " " .. creatureSpellID .. " " .. creatureName .. " " .. icon .. " " .. issummoned) end

Result

Prints all the information regarding your pets to the chat frame.
7555 Hawk Owl 10706 Interface\Icons\Ability_EyeOfTheOwl 1 
7553 Great Horned Owl 10707 Interface\Icons\Ability_EyeOfTheOwl nil