### Full Example of Custom Conditions and Variables Source: https://github.com/weakauras/weakauras2/wiki/Trigger-State-Updater-(TSU) A comprehensive example demonstrating various custom condition types, including select and boolean with a test function, along with event handling for state updates. This illustrates mixing and matching different configuration approaches. ```lua { additionalProgress = 1, expirationTime = true, stacks = true, unit = "string", var3 = { display = "colour", type = "select", values = { [1] = "red", [2] = "blue", [3] = "green", } }, spellUsable = { display = "Spell Usable", type = "bool", test = function(state, needle) return state and (IsUsableSpell(state.spellname) == (needle == 1)) end, events = { "SPELL_UPDATE_USABLE", "PLAYER_TARGET_CHANGED", "UNIT_POWER_FREQUENT", }, }, } ``` -------------------------------- ### Example WeakAura in User Mode Source: https://github.com/weakauras/weakauras2/wiki/Custom-Options This is an example of a WeakAura configuration that would be used in User Mode. It is a compressed string representing the aura's settings. ```compressedstring !vE1AVTTnu0FlRddOfOjq(TZ(wAQZAlCvYcDB(MQPLOK5MePkfPtsXG)TVZLus2oTaRlPnMpV3Z9CFrNmizvcRkHLr)dd1oBPujsy38PvlFF8IewUwzzYVjsIhmmH1ikZVvlv2e2BUz1QB(yc7XBYZBe2KRpB(0jtgnz0O5thn9IOrJsYpB8eiyztDj)PvIhXT(T0ewQRXQRcZZDQuRuRE5R2)H9Rd)AewNrTF9lFXsTruTFTSUXHpY0LAZ(1ns7(18kH917xNQvnIulDbSwMSw2Kkvf7xlkL2Z3V(kdVbtC7xxjBLdw9ZYD8kh2a4kvy4qE5ctLqz9QrYRGO)QtItuPlfnwPy)6YawsDMg6Qos8VxzfMm6sciJkooRJNXH4a(WH4P4)4m9MqTrwrIvQOZ4sLBCneGiDSXv6pI2yHe2rwqhkSIYssPaUsLKd0PePpZ61zsnihhiGAVTFPqj4ksNcR0DGgD2aBSvOYmcJK4rATDUYANLtOTIxO4ejkK54uqy)jWXxDyRgDgzMyaVwkG4Bez9UgRuLkZCkBp)DeV2zevCRvsw9TgUObBcRbrbW6eACpRrcYWRlrbrRbIGgJDZnW9kll5ExtjPcUj1bPf78R65KV6iFQvuv7DvgYy2jTCitJZA8bbFki0glfHy2QvP0z5LKQj6lMxDGbic3dPD6sNTM3dRCHRqstLTHc4MmIrcMFqBbd88x8QFVXT5LdE9WieTts9dF)VjSN6sOgpDWSlMI0PlIgpEgsLc5tCv6wTPnl8QfXRwChYP0QCzbLcB1ffWbHHXdsEtcoJUMYWMNeh1nEaTx7yiXX4NUPtdxmo68HjXdtUEYWHZMfnBE0WztgmDmLupzCs8i)Hgt)TxddH6Ahod3nI25qU(NQZqSvcZ1(j3Hn4wz69Ym72e2Lyow1xnGqpdEgJfdOQeiQVzBymggwfJrSsrHW0ASR6xGgMj24YZx9un017wS82R)0sSVFk3z4uXSAer((SMGCHRrSdrJmCl5JjSVC1LSvFHT6Y7GWCKszuzmi8(JERr4pk72flHW9RbLj4LKbPOAaDif5e9qZVazO7eRcl(rDgkWE2apLbIb(3BQ7iIwlZJCu)fj8KXHQhLwVBK0tc7TgDDM(bKq(rHYLW2XlDDrb0KbK3KgmK0XFlE6qSa7bVhW7kXH6vwMOj1i9hQtlbuTF9Vo6ezGzwF58vB9v3Oejuu4W99zsuHaKctzlnOwzjYE0u2FdAVq1jrwZwEz((1E8C(r9Ey(Z3d0OZNqqD0phuhFcuh3b1lj9z)VWlbg7w)2LCtH4ym)6wqNPDBkf)iy7VspSjMhPmu4uJiMa5B6W)wbpJIScq7FsVg)mFEu07egrp(Ae1C0SsB(Ltf5Kd8qi5VJcw5NTF9nTeZr0WWdXqV50aGPhKwf2w2fYDsavP224dO05KFOBtyDi)KqetJxrazXAq9AGO4z(AuwJUKI)ofFlrf)d4PTWfK(gs2BiPUHK5gsGBirTPpgURA3jMWSdMGuHEAEc)TW7EIT2RW26FhXotcruu8SVB4JuZjvbfiqXghIAgd3DyhVThmlQkKQWR0LH9OYWXZpGQuQDz3XVk078h4KM(ms5)xr5JzKl8fu152p26Ec4WWvu85rSdSviHiQ6RO2ZsDIb5CSk629LCyLse0sVcYZXEXtxFu0b6JijDBk1dAxjsx2akTqRZOujdL1HgNqW(NTvy0U6q215NqfZoQMNVZsmkw2ZNkx1gk955gYGo7i68Ojh769gsuNHCBjNEqwSxkh8ebBiw7F)gkl9KgVJuq959PJkT6mv7v2I8u6Tlu4IpKleEilu4vJzNAkZpYuIcnd8pEqXl)m6LrQoEaW4FHwNYCCTLlUgw6dAt29gEDc7((rs8U9)apZZiXZNUsxvxkqO6v(EU4bGOnNpRlt21lH6LAGnJquUL7PIWZjUMwn0SKD1DlwetBiP(Zaoh1mMLbHsl(LUgsK8B6DeuAVLyFP6N)09T3)5opLptw(frtkF1DOzBJlu0nHDTr(n6XQ8mY(2VE1QUKTqcKVli93ttvqxCr29TLuJIO6BC)3hcpri1)vKOkHDTUtl5nnF3Qum7ZxelBefWEcmRV6oDu0UwSdvnH6hpKqqY)o ``` -------------------------------- ### Example TSU Trigger Function Source: https://github.com/weakauras/weakauras2/wiki/Trigger-State-Updater-(TSU) This example demonstrates how to use the `states` helper methods to update player essence power levels. It removes states for unused essence slots and updates states for active ones. No explicit return value is needed as helper methods handle state change detection. ```lua function(states, event, ...) local currentEssence = UnitPower("player", Enum.PowerType.Essence) local maxEssence = UnitPowerMax("player", Enum.PowerType.Essence) for i = 1, 6 do if i > maxEssence then states:Remove(i) -- wipes states that are no longer needed else local value = currentEssence >= i and 1 or 0 local newState = { progressType = "static", value = value, total = 1 } states:Update(i, newState) end end -- no need to return true end ``` -------------------------------- ### Custom Texture Path Example Source: https://github.com/weakauras/weakauras2/wiki/Dynamic-Information Specifies how to reference custom texture files within WeakAuras. Ensure files are correctly formatted and placed within the WoW directory. ```lua Interface\customImages\myImage.tga ``` -------------------------------- ### Example: Fixing a Custom Trigger Event Source: https://github.com/weakauras/weakauras2/wiki/Deprecated-CLEU This example demonstrates how to identify and apply subEvent filters to a COMBAT_LOG_EVENT_UNFILTERED trigger by examining the custom trigger function and updating the 'Event(s)' box. ```lua -- these are EXAMPLES of how to do it CLEU:UNIT_DIED CLEU:SPELL_AURA_APPLIED:SPELL_AURA_APPLIED_DOSE:SPELL_AURA_REMOVED CLEU:SWING_DAMAGE:RANGE_DAMAGE:SPELL_DAMAGE ``` -------------------------------- ### Custom Sort Function Example in WeakAuras Source: https://github.com/weakauras/weakauras2/wiki/Custom-Dynamic-Group Implement a custom sort function to define the order of regions within a dynamic group. This example demonstrates a basic sort equivalent to the 'None' option, ordering by `dataIndex`. ```lua function(a, b) -- this is roughly equivalent to the "None" sort option return a.dataIndex <= b.dataIndex end ``` -------------------------------- ### Lazy Evaluation Example - WeakAuras.SortAscending Source: https://github.com/weakauras/weakauras2/wiki/Custom-Dynamic-Group Example demonstrating lazy evaluation for custom sorts. If your custom sort function consumes specific state keys, declare them in the 'Run On...' box to ensure correct functionality. Using 'changed' as a wildcard is possible but not recommended for performance. ```lua WeakAuras.SortAscending{"region", "state", "myKey"} ``` -------------------------------- ### TSU: Update Clones for Player Essence Source: https://context7.com/weakauras/weakauras2/llms.txt This TSU example updates clones to represent player essence levels. It creates or removes clones based on maximum essence and updates their static progress. ```lua -- Using helper methods on allstates: function(states, event, ...) local maxEssence = UnitPowerMax("player", Enum.PowerType.Essence) local curEssence = UnitPower("player", Enum.PowerType.Essence) for i = 1, 6 do if i > maxEssence then states:Remove(i) else states:Update(i, { progressType = "static", value = curEssence >= i and 1 or 0, total = 1, }) end end -- No need to return true when using helper methods end ``` ```lua -- Clear all clones: -- allstates:RemoveAll() ``` -------------------------------- ### Custom Variables Definition Source: https://github.com/weakauras/weakauras2/wiki/Custom-Code-Blocks Defines custom variables to be made available in Conditions. This example makes 'stacks', 'myVar', and 'unit' accessible. ```lua { stacks = true, myVar = { display = "My Var", type = "number", }, unit = "string", } ``` -------------------------------- ### Start Action Button Glow Effect Source: https://github.com/weakauras/weakauras2/wiki/Useful-variables-and-functions-within-WeakAuras Applies a glow effect to an action button frame, mimicking the default UI glow. Customization is available for color and animation speed. ```Lua LCG.ButtonGlow_Start(frame[, color[, speed]]]) ``` -------------------------------- ### Group by Frame - Custom Unit Frame Grouping Source: https://github.com/weakauras/weakauras2/wiki/Custom-Dynamic-Group This example demonstrates grouping regions by unit frames, with an option to ignore specific frames using a regular expression pattern. It utilizes WeakAuras.GetUnitFrame to find the appropriate frame for each unit. ```lua function(frames, activeRegions) for _, regionData in ipairs(activeRegions) do local unit = regionData.region.state and regionData.region.state.unit if unit then local frame = WeakAuras.GetUnitFrame(unit, { ignoreFrames = { "Grid2LayoutHeader2.*", -- target "Grid2LayoutHeader3.*", -- focus "Grid2LayoutHeader4.*" -- tot } }) if frame then frames[frame] = frames[frame] or {} tinsert(frames[frame], regionData) end end end end ``` -------------------------------- ### Custom Trigger Logic Function Example Source: https://github.com/weakauras/weakauras2/wiki/Aura-Activation-and-Deactivation Use this Lua function within a custom trigger to define complex activation conditions. It receives trigger states and returns true to show the display, false to hide it. ```lua function(trigger) return trigger[1] and (trigger[2] or trigger[3]); end ``` -------------------------------- ### Check Options Window State with WeakAuras.IsOptionsOpen Source: https://context7.com/weakauras/weakauras2/llms.txt Returns a boolean indicating if the WeakAuras configuration window (`/wa`) is open. This is useful for providing safe default values in custom code that might run before actual game data is available. ```lua -- Custom text function: show placeholder text while config is open function() if WeakAuras.IsOptionsOpen() then return "12.3s" -- preview value for configuration end if aura_env.state and aura_env.state.expirationTime then return string.format("%.1fs", aura_env.state.expirationTime - GetTime()) end end ``` -------------------------------- ### Import Aura Data with WeakAuras.Import Source: https://context7.com/weakauras/weakauras2/llms.txt Prepares aura data for import into WeakAuras, presenting a confirmation tooltip to the user. Supports importing single auras or groups with children. ```lua -- Import a single aura from a raw table local inData = { d = { id = "My Aura", uid = WeakAuras.GenerateUniqueID(), regionType = "icon", -- ...additional aura data fields... } } local status, msg = WeakAuras.Import(inData) if status ~= true then print("Import failed:", msg) end ``` ```lua -- Import a group with children local groupData = { d = { id = "My Group", regionType = "group" }, c = { { id = "Child One", regionType = "icon" }, { id = "Child Two", regionType = "aurabar" }, } } WeakAuras.Import(groupData, nil, function(id) print("Import complete, aura ID:", id) end) ``` -------------------------------- ### Create Symbolic Link for WeakAuras Addon (Windows) Source: https://github.com/weakauras/weakauras2/wiki/Lua-Dev-Environment On Windows, use mklink to create a symbolic link for the WeakAuras addon. This command links your repository's addon folder to the WoW Interface/Addons directory. ```batch > mklink /d "path\to\World of Warcraft\_retail_\Interface\Addons\WeakAuras" "path\to\repository\WeakAuras" symbolic link created for WeakAuras ===>> path\to\repositoy\WeakAuras ``` -------------------------------- ### Custom Check Function Example Source: https://github.com/weakauras/weakauras2/wiki/Custom-Code-Blocks This function is called to check if a condition should be activated. It receives an array of states across all triggers for a given aura. For example, to compare the remaining time of trigger 1 and trigger 2, use this structure. The function is automatically called every time any state changes. ```LUA function(states) if states[1].expirationTime and states[2].expirationTime then return states[1].expirationTime < states[2].expirationTime end end ``` -------------------------------- ### Provide Custom Duration Info Source: https://context7.com/weakauras/weakauras2/llms.txt Supply timed or static progress data to progress-capable displays. Use `select(5, WA_GetUnitBuff(...))` for timed mode and unit power/health functions for static mode. ```lua -- Timed mode: duration + expiration time (relative to GetTime()) function() local duration, expirationTime = select(5, WA_GetUnitBuff("player", "Rejuvenation")) if duration and duration > 0 then return duration, expirationTime end end ``` ```lua -- Static mode: current value, max value, true function() return UnitHealth("player"), UnitHealthMax("player"), true end ``` ```lua -- Mana percentage as static progress function() return UnitPower("player", 0), UnitPowerMax("player", 0), true end ``` ```lua -- Custom overlay on a progress bar: highlight final 5 seconds -- (Add Overlay button in trigger settings, then in the Overlay function): function() return 0, 5 -- absolute: from 0 to 5 seconds remaining end ``` ```lua -- Relative overlay: 1-second-wide section tracking the moving edge function() return "backward", 1 -- 1 second behind the progress edge end ``` -------------------------------- ### Get Active Conditions Variable Source: https://github.com/weakauras/weakauras2/wiki/Useful-variables-and-functions-within-WeakAuras Retrieves a table indicating the active state of each Condition associated with an Aura. ```APIDOC ## WeakAuras.GetActiveConditions(aura_env.id, aura_env.cloneId) ### Description Returns a table containing boolean values for each Condition defined on an Aura, indicating whether each condition is currently active. ### Parameters #### Args * `aura_env.id` (any) - The ID of the aura. * `aura_env.cloneId` (any) - The clone ID of the aura. ### Returns table - A table where keys represent condition indices and values are booleans indicating their active state. ### Example ```lua local conditions = WeakAuras.GetActiveConditions(aura_env.id, aura_env.cloneId) if conditions[2] and not conditions[3] then -- Code to execute if the second condition is active and the third is not. end ``` ``` -------------------------------- ### WeakAuras.Import Source: https://context7.com/weakauras/weakauras2/llms.txt Prepares aura data for import into WeakAuras, opening a confirmation tooltip for the user. It can import single auras or groups with children. ```APIDOC ## WeakAuras.Import ### Description Prepares aura data for import into WeakAuras, opening a confirmation tooltip for the user. ### Usage ```lua -- Import a single aura from a raw table local inData = { d = { id = "My Aura", uid = WeakAuras.GenerateUniqueID(), regionType = "icon", -- ...additional aura data fields... } } local status, msg = WeakAuras.Import(inData) if status ~= true then print("Import failed:", msg) end -- Import a group with children local groupData = { d = { id = "My Group", regionType = "group" }, c = { { id = "Child One", regionType = "icon" }, { id = "Child Two", regionType = "aurabar" }, } } WeakAuras.Import(groupData, nil, function(id) print("Import complete, aura ID:", id) end) ``` ``` -------------------------------- ### Clone WeakAuras Repository Source: https://github.com/weakauras/weakauras2/wiki/Lua-Dev-Environment Use this command to clone the WeakAuras repository to your local machine. Avoid cloning directly into the World of Warcraft folder. ```bash git clone https://github.com/WeakAuras/WeakAuras2.git ``` -------------------------------- ### Custom Rotate Animation Function Source: https://context7.com/weakauras/weakauras2/llms.txt Applies a linear 360-degree spin animation. Takes progress, start, and delta values. ```lua -- Rotate: linear 360-degree spin function(progress, start, delta) return start + (progress * 360) end ``` -------------------------------- ### Event Trigger: Encounter Start/End Source: https://context7.com/weakauras/weakauras2/llms.txt This Event trigger activates on ENCOUNTER_START and ENCOUNTER_END events. It captures the encounter name on start. ```lua -- Events: ENCOUNTER_START, ENCOUNTER_END -- Trigger: function(event, arg1, arg2, ...) if event == "ENCOUNTER_START" then aura_env.encounterName = arg2 return true end end ``` ```lua -- Untrigger: function(event, ...) return event == "ENCOUNTER_END" end ``` -------------------------------- ### Initialize LibCustomGlow Library Source: https://github.com/weakauras/weakauras2/wiki/Useful-variables-and-functions-within-WeakAuras Accesses the LibCustomGlow library using LibStub. This library provides functions for adding custom visual glows to UI elements. ```Lua local LCG = LibStub("LibCustomGlow-1.0") ``` -------------------------------- ### Custom Trigger: UNIT_HEALTH Event Source: https://github.com/weakauras/weakauras2/wiki/Custom-Code-Blocks Example of a custom trigger using the UNIT_HEALTH event. It checks if the player's health is above a certain threshold. ```lua function(event, unit) if unit == "player" then return UnitHealth("player") > 1000 end end ``` -------------------------------- ### Create a New Git Worktree for Classic Source: https://github.com/weakauras/weakauras2/wiki/Lua-Dev-Environment This command creates a new git worktree for developing WeakAuras Classic, allowing parallel development for both Retail and Classic versions from the same repository. ```bash # in your WeakAuras repository: git worktree add ../WeakAuras-classic ``` -------------------------------- ### Custom Trigger: SPELL_CAST_SUCCESS Event (CLEU) Source: https://github.com/weakauras/weakauras2/wiki/Custom-Code-Blocks Example of a custom trigger using the COMBAT_LOG_EVENT (CLEU) for SPELL_CAST_SUCCESS. It checks if the player successfully cast a spell. ```lua function(event, timestamp, subEvent, hideCaster, sourceGUID, sourceName, sourceFlags, sourceRaidFlags, destGUID, destName, destFlags, destRaidFlags, ...) if subEvent == "SPELL_CAST_SUCCESS" and sourceGUID == UnitGUID("player") then return true end end ``` -------------------------------- ### Using aura_env for Local Variables Source: https://github.com/weakauras/weakauras2/wiki/aura_env Assign variables to aura_env to limit their scope to the current aura. This example demonstrates storing an icon path and returning it. ```Lua --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 ``` -------------------------------- ### WeakAuras.IsOptionsOpen Source: https://context7.com/weakauras/weakauras2/llms.txt Returns a boolean indicating whether the WeakAuras configuration window (`/wa`) is currently open. This is useful for providing safe default values in custom code. ```APIDOC ## WeakAuras.IsOptionsOpen ### Description Returns a boolean indicating whether the WeakAuras configuration window (`/wa`) is currently open. Useful for providing safe default values in custom code that may run before real data is available. ### Usage ```lua -- Custom text function: show placeholder text while config is open function() if WeakAuras.IsOptionsOpen() then return "12.3s" -- preview value for configuration end if aura_env.state and aura_env.state.expirationTime then return string.format("%.1fs", aura_env.state.expirationTime - GetTime()) end end ``` ``` -------------------------------- ### Get Number of Equipped Set Items Source: https://github.com/weakauras/weakauras2/wiki/Useful-variables-and-functions-within-WeakAuras Retrieves the count of currently equipped items belonging to a specified item set. Requires a valid setID. ```Lua WeakAuras.GetNumSetItemsEquipped(setID) ``` -------------------------------- ### Custom Translate Animation Function Source: https://context7.com/weakauras/weakauras2/llms.txt Creates a circular orbit animation instead of a linear slide. Requires start and delta values for both X and Y axes. ```lua -- Translate: circular orbit instead of straight-line slide function(progress, startX, startY, deltaX, deltaY) local angle = progress * 2 * math.pi return startX + deltaX * math.cos(angle), startY + deltaY * math.sin(angle) end ``` -------------------------------- ### Return Texture Path String for Icon Info Source: https://github.com/weakauras/weakauras2/wiki/Custom-Code-Blocks Use this to return a direct texture path string. This is useful for Icon and Progress Bar Aura Types. ```Lua function() return "Interface\TargetingFrame\UI-RaidTargetingIcon_1" end ``` -------------------------------- ### Import Source: https://github.com/weakauras/weakauras2/wiki/API-Documentation Prepares and imports aura data into WeakAuras. This function can import raw or compressed data and optionally update existing auras or trigger a callback upon completion. ```APIDOC ## Import ### Description Prepares aura data to be imported into WeakAuras. ### Parameters - `inData` (table) - Required: Payload to be imported. Must be a table, either raw or compressed and encoded using [LibDeflate](https://github.com/safeteeWoW/LibDeflate). Table must be of the following format: ```lua inData = { d = {...}, -- required: primary aura data c = { {...}, {...}, ...} -- optional: array of child aura data } ``` - `target` (table | string) - Optional: May either be a table which exists in the database already, or a uid which exists in the database already. If `target` points to an aura which already exists, then the payload will be processed as an update for the existing aura. Otherwise, the database will be searched for a possible match. - `callbackFunction` (function) - Optional: Function to be called on completion of import process. Returns the ID of the Aura if import was succesful. ### Return Values `WeakAuras.Import` returns whether or not it successfully processed the payload and opened a tooltip for the user to begin the installation. If the first return value is not `true`, then the second return value will be a string explaining the problem found. ### Example ```lua WeakAuras.Import(inData, [target], [callbackFunction]) ``` ``` -------------------------------- ### Get Active Conditions with WeakAuras.GetActiveConditions Source: https://github.com/weakauras/weakauras2/wiki/Useful-variables-and-functions-within-WeakAuras Retrieves a table of booleans indicating the active state of each Condition on an Aura. Useful for conditional logic within custom auras. ```Lua local conditions = WeakAuras.GetActiveConditions(aura_env.id,aura_env.cloneId) if conditions[2] and not conditions[3] then -- Code to execute if the second condition is active and the third is not ``` -------------------------------- ### Import Aura Data into WeakAuras Source: https://github.com/weakauras/weakauras2/wiki/API-Documentation Prepares and imports aura data. The `inData` parameter must be a table containing primary aura data (`d`) and optionally child aura data (`c`). The `target` parameter can specify an existing aura for updates, and `callbackFunction` can be provided for completion notification. ```lua WeakAuras.Import(inData, [target], [callbackFunction]) ``` ```lua inData = { d = {...}, -- required: primary aura data c = { {...}, {...}, ...} -- optional: array of child aura data } ``` -------------------------------- ### Get Active Conditions for an Aura Source: https://context7.com/weakauras/weakauras2/llms.txt Returns a table of booleans indicating which conditions are currently active for a given aura or clone. Use within a custom code block. ```lua -- In a custom code block: local conditions = WeakAuras.GetActiveConditions(aura_env.id, aura_env.cloneId) -- conditions[1] => true if the first Condition tab entry is currently active if conditions[2] and not conditions[3] then -- Condition 2 active, condition 3 not active aura_env.region:SetAlpha(0.5) end ``` -------------------------------- ### Reading Custom Options from aura_env.config Source: https://context7.com/weakauras/weakauras2/llms.txt Demonstrates how to read various types of user-defined options (boolean, number, color table, string, dropdown index) from `aura_env.config` in custom code blocks. ```lua -- Author mode: define options in the Custom Options tab UI. -- User mode: the user sees widgets; values are stored in aura_env.config. -- In any custom code block, read options: local showAll = aura_env.config["showAllDebuffs"] -- bool: true/false local threshold = aura_env.config["healthThreshold"] -- number local color = aura_env.config["highlightColor"] -- table: {r, g, b, a} local spellName = aura_env.config["trackedSpell"] -- string local mode = aura_env.config["displayMode"] -- number (dropdown index, 1-based) -- Example: conditional trigger based on user threshold function(event, unit) if unit == "player" or event == "STATUS" then local threshold = aura_env.config and aura_env.config["threshold"] or 30 return UnitHealth("player") / UnitHealthMax("player") * 100 < threshold end end -- Example: use color option to tint the region -- In On Show custom code: if aura_env.config and aura_env.config["glowColor"] then local c = aura_env.config["glowColor"] local LCG = LibStub("LibCustomGlow-1.0") LCG.PixelGlow_Start(aura_env.region, {c[1], c[2], c[3], c[4]}, 8, 0.25) end -- Array group: aura_env.config["rotation"][index].spellID for i, entry in ipairs(aura_env.config["rotation"] or {}) do print(i, entry.spellID, entry.enabled) end ``` -------------------------------- ### Get Spell Texture for Icon Info Source: https://github.com/weakauras/weakauras2/wiki/Custom-Code-Blocks Use this to return a spell's texture path based on its ID. This is useful for Icon and Progress Bar Aura Types. ```Lua function() return GetSpellTexture(123456) end ``` -------------------------------- ### Custom Grow: Anchor Clones to Nameplates by Unit Source: https://context7.com/weakauras/weakauras2/llms.txt Anchors cloned regions to specific nameplates based on the `state.unit` of each region. Requires `C_NamePlate.GetNamePlateForUnit`. ```lua -- Group by Frame: anchor clones to nameplates based on state.unit function(newPositions, activeRegions) local frames = {} for _, rd in ipairs(activeRegions) do local unit = rd.region.state and rd.region.state.unit if unit then local frame = C_NamePlate.GetNamePlateForUnit(unit) if frame then frames[frame] = frames[frame] or {} tinsert(frames[frame], rd) end end end for frame, regionsData in pairs(frames) do local x = -(#regionsData - 1) * 20 newPositions[frame] = {} for i, rd in ipairs(regionsData) do newPositions[frame][rd] = { x + (i - 1) * 40, 0 } end end end ``` -------------------------------- ### Custom Overlay - Absolute Position Source: https://github.com/weakauras/weakauras2/wiki/Dynamic-Information Defines an overlay's position using absolute start and end points relative to the total duration. Useful for fixed segments. ```lua return 0, 5 ``` ```lua return UnitPowerMax("player")-200000, UnitPowerMax("player") ``` -------------------------------- ### Create a new topic branch Source: https://github.com/weakauras/weakauras2/blob/main/CONTRIBUTING.md Before making changes, create a new branch based on the main branch to isolate your work. ```bash git checkout -b my-topic-branch ``` -------------------------------- ### Commit and push changes Source: https://github.com/weakauras/weakauras2/blob/main/CONTRIBUTING.md Stage, commit, and push your changes to your feature branch. ```bash git commit -a -m "commit-description" git push ``` -------------------------------- ### Accessing Current Encounter Metadata Source: https://context7.com/weakauras/weakauras2/llms.txt Retrieves and prints metadata about the current boss encounter, including ID, zone ID, and boss GUIDs. Available only during an active encounter. ```lua -- Available during an active encounter: local enc = WeakAuras.CurrentEncounter if enc then print("Encounter ID:", enc.id) print("Zone Map ID:", enc.zone_id) for guid, _ in pairs(enc.boss_guids) do print("Boss GUID:", guid) end end ``` -------------------------------- ### Invert Aura Progress Direction Source: https://github.com/weakauras/weakauras2/wiki/Editing-Aura-Regions Reverses the direction of progress bars or cooldowns. For example, a progress bar that normally fills from left to right would fill from right to left. ```lua region:SetInverse(true) -- Inverts the progress direction ``` -------------------------------- ### Custom Duration Info (Value Based Mode) Source: https://github.com/weakauras/weakauras2/wiki/Dynamic-Information Provides current and maximum values for static progress displays. The third return value 'true' indicates static mode. ```lua function() --Value Based local current = UnitHealth("player") local max = UnitHealthMax("player") return current, max, true end ``` -------------------------------- ### Custom Stack Info Function Source: https://github.com/weakauras/weakauras2/wiki/Dynamic-Information Returns a number for stack count. Use `%s` for standard display or `%stacks` to show 0 when applicable. ```lua return stacks ```