Skip to content

Useful variables and functions within WeakAuras

SpatenLa edited this page Jul 4, 2024 · 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 WarcraftWiki 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.

String shortening

WA_Utf8Sub(string, numCharacters)

Args
  • string: the string to be shortened
  • numCharacters - number: The number of characters the string should be reduced to
Returns

The function shortens strings, with the advantage over a simple string.sub call of not tripping up on "non-standard" characters (ones that take more than one byte). This is especially useful for names in WoW as shortening a name like Légóólás would cause issues.


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

WeakAuras.GetActiveConditions(aura_env.id,aura_env.cloneId)

Very similar to the "triggers" table mentioned above, but this function returns a table containing booleans for each Condition your Aura contains.

For example,

local conditions = WeakAuras.GetActiveConditions(aura_env.id,aura_env.cloneId)
if conditions[2] and not conditions[3] then

This would run the following code if the second Condition on the Aura were active while the third was not.

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.GetNumSetItemsEquipped(setID)

If given a valid setID then it will return the number of items from that set that are currently equipped.

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.

Custom Glows

Custom glow functions are contained within a library.

To access the library use:
local LCG = LibStub("LibCustomGlow-1.0")

Pixel Glow

LCG.PixelGlow_Start(frame[, color[, numberOfLines[, speed[, length[, thickness[, xOffset[, yOffset[, border[ ,key]]]]]]]])
Arguments
  • frame - UI element - Target frame to set glowing.
  • color - table - {red,green,blue,alpha}, Color and opacity of lines, from 0 to 1. Default value is {0.95, 0.95, 0.32, 1}.
  • numberOfLines - number - Number of lines. Default value is 8.
  • speed - number - Speed of the animation, set to negative to invert direction of rotation. Default value is 0.25.
  • length - number - The length of the lines, in pixels. If not set then the default value will automatically adjust depending on region size and number of lines.
  • thickness - number Thickness of lines in pixels. Default value is 2.
  • xOffset - number - Horizontal offset of glow relative to region border, in pixels.
  • yOffset - number - Vertical offset of glow relative to region border, in pixels.
  • border - boolean - set to true to create border under lines. Defaults to true.
  • key - An arbitrary "key" for this specific glow. This allows for multiple glows on one frame, so you can specify stopping the glow, using this key.

To stop the glow use LCG.PixelGlow_Stop(frame[, key]) (key optional)

Autocast Shine

LCG.AutoCastGlow_Start(frame[, color[, numberOfParticleGroups[, speed[, scale[, xOffset[, yOffset[, key]]]]]]])
Arguments
  • frame - UI element - Target frame to set glowing.
  • color - table - {red,green,blue,alpha}, Color and opacity of lines, from 0 to 1. Default value is {0.95, 0.95, 0.32, 1}.
  • numberOfParticleGroups - number - Number of groups of particles, each of which contain 4 particles. Default value is 4.
  • speed - number - Speed of the animation, set to negative to inverse direction of rotation. Default value is 0.125.
  • scale - number - The scale of particles. Defaults to 1
  • xOffset - number - Horizontal offset of glow relative to region border, in pixels.
  • yOffset - number - Vertical offset of glow relative to region border, in pixels.
  • key - An arbitrary "key" for this specific glow. This allows for multiple glows on one frame, so you can specify stopping the glow, using this key.

To stop the glow use LCG.AutoCastGlow_Stop(frame[, key]) (key optional)

Action Button Glow

This glow looks like the default glow

LCG.ButtonGlow_Start(frame[, color[, speed]]])
Arguments
  • frame - UI element - Target frame to set glowing.
  • color - table - {red,green,blue,alpha}, Color and opacity of lines, from 0 to 1. Default value is {0.95, 0.95, 0.32, 1}.
  • speed - number - Speed of the animation, set to negative to inverse direction of rotation. Default value is 0.125.

To stop glow the use LCG.ButtonGlow_Stop(frame)

Clone this wiki locally