Wowpedia

We have moved to Warcraft Wiki. Click here for information and the new URL.

READ MORE

Wowpedia
No edit summary
(mention SPELL_POWER_*)
Line 3: Line 3:
 
powerType, powerTypeString = UnitPowerType(unit);
 
powerType, powerTypeString = UnitPowerType(unit);
   
The API is not 100% documented after 3.1 patch, some vehicle powers are not counted for.
+
The API is not 100% documented after 3.1 patch, some vehicle powers are not counted for. Player-related power types should be referred to using the SPELL_POWER_* names defined in FrameXML/Constants.lua rather than the raw numbers below.
   
 
==Parameters==
 
==Parameters==

Revision as of 19:57, 26 July 2010

Returns a number corresponding to the power type (e.g., mana, rage or energy) of the specified unit.

powerType, powerTypeString = UnitPowerType(unit);

The API is not 100% documented after 3.1 patch, some vehicle powers are not counted for. Player-related power types should be referred to using the SPELL_POWER_* names defined in FrameXML/Constants.lua rather than the raw numbers below.

Parameters

Arguments

unit
UnitId - the unit whose power type to query.

Returns

powerType
Integer - the power type:
  • 0 = Mana
  • 1 = Rage
  • 2 = Focus (hunter pets)
  • 3 = Energy
  • 4 = Happiness
  • 5 = Runes
  • 6 = Runic Power
  • ? = Ammoslot (vehicles, 3.1)
  • ? = Fuel (vehicles, 3.1)
powerTypeString
String - also the power type:
  • "MANA"
  • "RAGE"
  • "FOCUS"
  • "ENERGY"
  • "HAPPINESS"
  • "RUNES"
  • "RUNIC_POWER"
  • "AMMOSLOT" (vehicles, 3.1)
  • "FUEL" (vehicles, 3.1)

Example

local t = {[0] = "mana", [1] = "rage", [2] = "Focus", [3] = "Energy", [4] = "Happiness", [5] = "Runes", [6] = "Runic Power"};
DEFAULT_CHAT_FRAME:AddMessage(UnitName("player") .. "'s " .. t[UnitPowerType("player")] .. ": " .. UnitMana("player"));

Result

Displays the player's current mana/rage/energy in the default chat frame.