Skip to content

Useful variables and functions within WeakAuras

asakawa-k edited this page Oct 28, 2018 · 19 revisions

This page is for built-in features in WeakAuras that were either added specifically to help custom coders or are part of WeakAuras code base normally for the add-on itself. Since these built-in variables and functions to the add-on itself they are subject to change at the developer's discretion.

Helper Functions

With WoW API 8.0's change to the way auras (buffs / debuffs) can be queried, WeakAuras added some Helper Function that were specifically made to be used by Custom Aura makers to make this a bit easier. Since they were being added a couple of other useful functions were added at the same time.

Buff/debuff querying

WA_GetUnitAura(unit, spell, filter)
WA_GetUnitBuff(unit, spell, filter)
WA_GetUnitDebuff(unit, spell, filter)

Args
  • unit - string - a valid unitID
  • spell - string or number - Spell Name or Spell ID
  • filter - string - Ultimately the helper functions call the Blizzard base functions so the same filter strings can be used.
Returns

See this Wowpedia link for the vars returned by these functions.

Used to query specific buffs or debuffs on specific units. After 8.0 Blizzard removed querying by spell name from the base functions and provided their own helper function. However that function is awkward to use and fairly slow. The aim with these functions was to maintain the syntax people were used to.

Group Iteration

WA_IterateGroupMembers(reversed, forceParty)

Args
  • reversed - boolean - iterate backwards through the group.
  • forceParty - boolean - only iterate the player's party, and not the whole raid.

Iterates through the player's group (party or raid), returning a unit for each member. A simple example that would print the names of your raid members:

for unit in WA_IterateGroupMembers() do
    print( UnitName(unit) )
end

Class Colouring

WA_ClassColorName(unit)

Args
  • unit - string - a valid unitID
Returns

The function returns the name of the unit with "Escape Sequence" formatting to colour the text appropriately for their class.


The rest of this article covers elements of WeakAuras that were not specifically created for users. Therefore, while they can be very useful and certainly won't be altered without due consideration, their usefulness to custom Aura creators won't necessarily be factored in to any changes made to them.

Variables

TriggerState

WeakAuras.triggerState[aura_env.id]
The triggerState table for each Aura contains all the state information for the triggers in an Aura, including any clone states they might carry. WeakAuras.triggerState[aura_env.id].triggers
The most commonly useful part of this table is the triggers table. The current status of each of the Aura's triggers are saved in this table as a Boolean (true/false) value.
For example, WeakAuras.triggerState[aura_env.id].triggers[3] returns true if the third trigger in the WeakAura is active.

WeakAuras.CurrentEncounter

WeakAuras.CurrentEncounter is a table that holds some encounter information for a fight. You can access the information via the following internal variables:

  • id = encounter_id
  • zone_id = ZoneMapID
  • boss_guids = {}

Functions

WeakAuras.ScanEvents()

WeakAuras.ScanEvents is a built-in function that is used by Weak Auras to pass in actual game events to the Add-on. Players can use this function to create custom events for their own needs which can be used to send events to either trigger or pass information to the aura itself or another aura.

The format for WeakAuras.ScanEvents is as follows:

WeakAuras.ScanEvents("CUSTOM_EVENT_NAME", argument1, argument2, ...)

Once this function is executed it will trigger an event you can capture using the event name you specified the same way you would use any normal WoW event. See Event for more information on how to use them.

Example

https://wago.io/4ypVLlCqb uses ScanEvents to pass information between two auras. Also uses aura_env.

WeakAuras.IsOptionsOpen()

WeakAuras.IsOptionsOpen() is a useful function to check if the options menu in WeakAuras (accessed by /wa) is open. You can use this function as a 'default' for any text or auras you have that may not have any data loaded while the options are open. This functions returns a basic boolean value.

if WeakAuras.IsOptionsOpen() then
    --Do default code when open
else
    --Do normal code when the options is not open.
end

WeakAuras.GetAuraTooltipInfo()

WeakAuras.GetAuraTooltipInfo() is a function within WeakAuras that parses an aura's (buff/debuff) tooltip to fetch information that can otherwise be difficult to acquire.

tooltipText, debuffType, tooltipSize = WeakAuras.GetAuraTooltipInfo(unit, index, filter)

Arguments

  • unit - A valid UnitID (e.g. "target", "focus", "raid5")
  • index - The index of the specific aura
  • filter - CANCELABLE, HARMFUL, HELPFUL, NOT_CANCELABLE, PLAYER, RAID. Multiple filters can be used separated with a "|"

Returns

  • tooltipText - All the text in the main area of the tooltip.
  • debuffType - Curse, Disease, Magic, Poison if applicable.
  • tooltipSize - In most cases this will be the most useful value. The function strips out other text and returns the main number value on the tooltip.