Skip to content
asaka-wa edited this page Apr 29, 2020 · 30 revisions

Actions

On Init

  • No function() ... end required.
  • Nothing sent in.
  • No return expected.

Init does not run each time the Aura is loaded, it runs once when the aura is first loaded then never again until a UI reload/restart or if WA config is opened and changes made to this code block or to Custom Options.

This code block is exceptionally useful for creating settings (any settings that users may want to alter should be done with Custom Options), tables of data, or functions. Anything that will be used throughout your Aura, or repeatedly by a function. Create variables like this in the aura_env table.

If the Aura you're making produces clones then this code block runs before they exist and so aura_env.state won't exist and aura_env.region will refer to the "base" Aura, not any clones you create later.

On Show

  • No function() ... end required.
  • Nothing sent in.
  • No return expected.

On Show runs once when the Aura as a whole change from not being active to being active. Then will not run again until it hides, and shows again.

If the Aura you're making produces clones then this code block will run for each clone that is shown. And aura_env.state and aura_env.region carry that clone's info.

On Hide

  • No function() ... end required.
  • Nothing sent in.
  • No return expected.

On Hide runs once when the Aura as a whole change from being active to not being active. Then will not run again until it shows, and hides again.

If the Aura you're making produces clones then this code block will run for each clone that hides. And aura_env.state and aura_env.region carry that clone's info.

Chat Message - Custom Code

This code block is accessed by using the Chat Message option, with %c in the Message text. The string(s) you return will be inserted into the message that you send.

Although it's likely that Custom Text functions in Actions will be much simpler than those in Display, all the info is the same so see below for extensive details

Display

Custom Text

If the trigger currently providing Dynamic Info uses "timed" duration info (e.g. buff duration) then:
function(expirationTime, duration, progress, formatedDuration, name, icon, stacks)
  • expirationTime - number When the displayed timer will expire, relative to GetTime()
  • duration - number The total number of seconds, e.g. 123
  • progress - string A formatted string showing remaining duration, equivalent of the %p text replacement
  • formatedDuration - string A formatted string showing minutes if applicable, e.g. 2:03, equivalent of the %t text replacement
  • name - string Whatever string the active trigger carries on its Name Info, equivalent of the %n text replacement
  • icon - string A formatted string with the Escape Sequences needed to display the Dynamic Info's icon in text, equivalent to the %i text replacement.
  • stacks - number The value carried by the Dynamic Info's Stacks, equivalent to %s

Despite looking like a number when below a minute, the "progress" value is actually a formatted string and shouldn't be used for arithmetic. If you need a remaining duration in your custom function then calculate yourself. e.g.

function()
  if aura_env.state and aura_env.state.duration and aura_env.state.duration > 0 then
    local remaining = aura_env.state.expirationTime - GetTime()
    return remaining > 3600 and ceil(remaining/3600).."h" or remaining > 60 and ceil(remaining/60).."m" or floor(remaining)
  end
end
If the trigger currently providing Dynamic Info uses "static" duration info (e.g. health values) then:
function(total, value, value, total, name, icon, stacks)
  • total - number The total or max value, equivalent to the %t text replacement
  • value - number The current value carried by dynamic Info, equivalent to the %p text replacement
  • value and total are repeated just to match argument positions with those with timed info.
  • Other args are as above.
Expected return:
return string[, string, string]
  • You can return multiple values.
  • You can return nil, it will be handled as an empty string.
"Update Custom Text On..."

Above this code block in the interface is a setting "Update Custom Text On..."

  • "Trigger Update" will fire the custom function when the Dynamic Info from any trigger in the Aura changes in any way. It will not fire when a custom trigger returns true from its trigger function unless that custom trigger also adjusts one of the Dynamic Infos it carries
  • "Every Frame" will fire the custom function every time the screen redraws (your Frames Per Second). This should be avoided where possible, since it means it will often be running when there is no change to update. When it is necessary though, don't worry too much, just code your function with efficiency in mind. Any application where you're outputting a timer will inevitably require "Every Frame".
Useful further reading:

Custom Anchor Function

The custom anchor function is updated on trigger update and should return a frame.

This example paired with a "cast" trigger with unit = "player" will anchor the region to your target's nameplate

function()
    if aura_env.state.destUnit then
        return C_NamePlate.GetNamePlateForUnit(aura_env.state.destUnit)
    end
end

For dynamically anchoring multiple auras to multiple frames, refer to dynamic group Custom Grow Functions and Group by Frame