Lore archive · Warcraft Wiki, 2023 dump
API UnitPowerType
Last wiki revision 2022-11-13
Returns a number corresponding to the power type (e.g., mana, rage or energy) of the specified unit. powerType, powerToken, altR, altG, altB = UnitPowerType(unit [, index])
- unit: : UnitId - The unit whose power type to query.
- index: - Optional value for classes with multiple powerTypes. If not specified, information about the first (currently active) power type will be returned.
- powerType:Enum.PowerType - the ID corresponding the the unit's queried power type.
- powerToken: - also the power type:
- "MANA"
- "RAGE"
- "FOCUS"
- "ENERGY"
- "HAPPINESS"
- "RUNES"
- "RUNIC_POWER"
- "SOUL_SHARDS"
- "ECLIPSE"
- "HOLY_POWER"
- "AMMOSLOT" (vehicles, 3.1)
- "FUEL" (vehicles, 3.1)
- "STAGGER" (vehicles, 5.1)
- "CHI"
- "INSANITY"
- "ARCANE_CHARGES"
- "FURY"
- "PAIN"
- altR: - Alternative red component for this power type, see details. Nil for most of the standard power types.
- altG: - Alternative green component for this power type, see details. Nil for most of the standard power types.
- altB: - Alternative blue component for this power type, see details. Nil for most of the standard power types.
The following snippet displays the player's current mana/rage/energy/etc in the default chat frame. local t = {[0] = "mana", [1] = "rage", [2] = "focus", [3] = "energy", [4] = "happiness", [5] = "runes", [6] = "runic power", [7] = "soul shards", [8] = "eclipse", [9] = "holy power"} print(UnitName("player") .. "'s " .. t[UnitPowerType("player")] .. ": " .. UnitPower("player"))
- Colors of all typical power types are stored in the PowerBarColor global table. Some special types may implement their own color as returned by the 3rd to 5th return values of UnitPowerType. For most of the standard power types they return nil however. FrameXML implements it the following way (with a fallback to "MANA"):
local powerType, powerToken, altR, altG, altB = UnitPowerType(UnitId); local info = PowerBarColor[powerToken]; if ( info ) then --The PowerBarColor takes priority r, g, b = info.r, info.g, info.b; else if ( not altR) then -- Couldn't find a power token entry. Default to indexing by power type or just mana if we don't have that either. info = PowerBarColor[powerType] or PowerBarColor["MANA"]; r, g, b = info.r, info.g, info.b; else r, g, b = altR, altG, altB; end
Source
https://warcraft.wiki.gg/wiki/API_UnitPowerType · retrieved 2023-11-13 · CC BY-SA 4.0
Converted from wikitext with templates, tables and images removed, so some sentences may be missing values.
This archive predates WoW: Forever. For collected gameplay facts see the Forever database. Search the archive.