aura_env - WeakAuras/WeakAuras2 GitHub Wiki
aura_env
aura_env is a built-in local table at the top of each aura declaration. Variables declared in this table will have their scope limited to the containing aura. aura_env can be accessed as global variables by functions within the current aura while remaining invisible to other auras.
To use aura_env for your own variables, simply assign it as a prefix to your variable name. An example of its use would be:
--Custom Trigger Function
function()
-- Select the icon for either Moonkin form or Bear form.
aura_env.icon = select(2, WA_GetUnitBuff("player", "Moonkin Form")) or select(2, WA_GetUnitBuff("player", "Bear form"))
return aura_env.icon -- If an icon is present, this will return true.
end
-- Custom Icon Function
function()
-- Return the Icon we found. (Moonkin, Bear, or None)
return aura_env.icon
end
Within aura_env
aura_env currently has 5 values id, cloneId, region, state and states.
idsimply outputs the name of the current aura.cloneIdis used with "Trigger State Updater" where it will return unique ID for each state.regionis the region of the aura. See here for more.stateis a table that stores information about the current state. The current state is the one that the aura is pulling dynamic information from. See below for more information.statesis a table that stores the state information of every trigger, similar tostate. It is not accessible from trigger functions.aura_env.states[2]would access the state of the second trigger.
savedis a storage auras can use to store data across sessions
Within aura_env.state and aura_env.states
The values contained within the state depend on the type of trigger being used. Some potentially useful ones are:
aura_env.state.show- a simple and quite useful boolean for whether the trigger is active or notaura_env.state.stacksaura_env.state.durationaura_env.state.expirationTimeaura_env.state.iconaura_env.state.spellId
All text replacements are valid state values, except the one-letter replacements. These can be found in the tooltip when mousing over the Display Text box in the Display tab, as seen here. %percenthealth would equate to aura_env.state.percenthealth, for example.
Be especially careful to catch nil values from these variables before using them in things like custom animation functions.