"Region" is a general term in the WoW UI for a type of frame that can hold content. On this page, however, "Region" will refer specifically to the base frame of any Aura. For the most part WeakAuras provides settings in its config for changes you might want to make to Aura regions or their child frames, but advanced users can tweak additional settings or change things dynamically through custom code. It should be noted that doing so is moving out of "supported" uses of WeakAuras, so there can be no guarantee that changes made in future development won't affect work you do.
Aura base regions can be accessed from within the Aura with aura_env.region (which will return the specific clone region if called from code within a clone) or from outside with WeakAuras.GetRegion(id, cloneId).
Note: Editing Aura regions in code can be very useful but should always be viewed as a last resort. Most properties that you might adjust in code can be adjusted via the Conditions tab and that should always be the method used if at all possible.
Note2: You may see some auras which access WeakAuras.regions. This is a internal data structure of WeakAuras and is subject to change without prior warnings. Use GetRegion as a mildly safer alternative.
Some Basic Examples
-- Set the width aura_env.region:SetRegionWidth(100) -- Set the height aura_env.region:SetRegionHeight(150)
Common/useful Region functions
All used with aura_env.region:FunctionName()
Color(r,g,b,a)
- Main colour output of the aura. Icon colour for Icons, bar colour for Progress Bars, etc.
SetAnchor(anchorPoint, relativeTo, relativePoint)
SetOffset(x,y)
SetOffsetRelative(x,y)
SetOffsetAnim(x,y)
SetDesaturated(bool)
SetDurationInfo(duration, expirationTime, static, inverse)
- Overrides the current cooldown/progress information of the aura. See here for more.
SetGlow(bool)
SetIcon(iconID|iconPath)
- Used with Icons and the small Icon in Progress Bars. Overrides the
icon
Dynamic Info.SetTexture()
for Texture auras.
- Used with Icons and the small Icon in Progress Bars. Overrides the
SetInverse(bool)
- Reverses the cooldown/progress direction.
SetName(string)
- Overrides the
name
dynamic info
- Overrides the
SetStacks(number)
SetOrientation("HORIZONTAL"|"HORIZONTAL_INVERSE"|"VERTICAL"|"VERTICAL_INVERSE")
- Progress Bar orientation.
The functions listed above are all specific to WeakAuras and it's outputs. A full list of the methods inherited by a basic frame can be found here.
Examples of use:
local region = aura_env.region region:Color(1,0,0,0.5) -- Sets the aura to red and half opacity region:SetAnchor("BOTTOMLEFT", WeakAuras.GetRegion("Other Aura"), "TOPRIGHT") -- Anchors the aura to another aura. region:SetOffset(0, 10) -- Sets aura's anchored offset to the coordinate at 0, 10. region:SetOffsetRelative(0, 10) -- Changes the aura's anchored offset relative to its normal offset. Up by 10 pixels. region:SetDesaturated(true) -- Makes the icon/texture greyscale region:SetDurationInfo(5, GetTime()+5) -- Gives the aura new duration info to last 5 seconds from when this code is run region:SetDurationInfo(UnitHealth("player"), UnitHealthMax("player"), true, true) -- Sets the aura's progress to be static, not timed, using the players health as the current value and their max health as the max value. This example is also inverts the progress bar so it grows the opposite way. region:SetGlow(true) -- Makes the aura glow region:SetIcon(132089) -- Sets the aura's icon to the Rogue's Stealth icon. https://www.wowhead.com/icons can help find icon IDs. region:SetInverse(true) -- Inverts the progress direction region:SetName(UnitName("player")) -- Sets the aura's `name` dynamic info to be the player's character name region:SetStacks(UnitPower("player", 4)) -- Sets the aura's `stacks` dynamic info to be the player's current Combo Points region:SetOrientation("VERTICAL") -- Changes the progress bar's orientation to be vertical.
Sub-elements
Additional frames can be added to the base Aura in the display tab via the "Sub-elements" section. These can be reordered to control how these frames layer
subtext
(text frame)subborder
(border frame)subbarmodel
(model frame)
These may be accessed via aura_env.region.subRegions
, an array containing all of the elements listed in the Display tab of an aura. The order of the elements in the array reflects the order in Display tab, but to serve as a quick example of using the subRegions table, you could find a text element like so:
for i, subregion in ipairs(aura_env.region.subRegions) do if subregion.type == "subtext" then -- do stuff end end
Clones
aura_env.region
will give the "current" region in a "cloning Aura" when used within the clone's functions (custom text, animations, Actions, etc.) "Cloning Auras" being those that use auto-clone
options in their triggers (aura-group/multitrigger, some event triggers etc.) or custom triggers that use the Trigger State Updater to create multiple outputs. If you ever need to acquire clone regions and aura_env.region
isn't an option then you can use:
WeakAuras.GetRegion("Aura name/ID", "Aura clone ID")
原文:https://github.com/WeakAuras/WeakAuras2/wiki/Editing-Aura-Regions
- 本文固定链接: https://www.fengshen.cn/2023/11/editing-aura-regions/gameofwind/
- 转载请注明: fengshen 发表于 Dream of Wind | 一梦风神
