Custom code in WeakAuras allows you to write Lua scripts for triggers, actions, animations, and display logic. This provides unlimited flexibility for creating sophisticated, custom behavior.
Custom code runs in the WoW Lua environment. Bugs can cause errors or performance issues. Test thoroughly!
function() // Runs every frame while shown local elapsed = GetTime() - (aura_env.lastUpdate or 0) if elapsed > 1 then aura_env.lastUpdate = GetTime() // Do periodic work endend
Throttle every frame code to avoid performance impact.
function() local _, class = UnitClass("player") if class == "PRIEST" then return "Interface\\Icons\\Spell_Holy_PowerWordShield" elseif class == "WARRIOR" then return "Interface\\Icons\\Ability_Warrior_ShieldMastery" end return "Interface\\Icons\\INV_Misc_QuestionMark"end
// Time formattingWeakAuras.TimeToString(seconds) -- "1m 30s"// Text replacementWeakAuras.ReplaceRaidMarkerSymbols(text)// Model loadingWeakAuras.SetModel(model, path, isUnit, displayInfo)
aura_env.values = aura_env.values or {}function(allStates, event, ...) // Track up to 5 combo points for i = 1, 5 do local cloneId = "cp" .. i allStates[cloneId] = allStates[cloneId] or {} local active = i <= GetComboPoints("player", "target") allStates[cloneId].show = active allStates[cloneId].changed = true end return trueend
aura_env.damage = aura_env.damage or {}function(event, timestamp, subevent, ...) if subevent ~= "SPELL_DAMAGE" then return end local sourceGUID = select(1, ...) local amount = select(12, ...) if sourceGUID == UnitGUID("player") then aura_env.damage.total = (aura_env.damage.total or 0) + amount aura_env.damage.lastAmount = amount aura_env.damage.lastTime = GetTime() endend
// Access saved variableslocal myAddonData = MyAddonDB or {}// Use in triggerfunction() if myAddonData.someValue > 100 then return true end return falseend
function() local success, result = pcall(function() // Your code here return UnitHealth("player") < 1000 end) if not success then print("WeakAuras Error:", result) return false end return resultend
aura_env.throttle = 0.5 // secondsaura_env.lastUpdate = 0function() local now = GetTime() if now - aura_env.lastUpdate >= aura_env.throttle then aura_env.lastUpdate = now // Do work return true end return falseend
function() local criteria = { UnitHealth("player") < 10000, UnitPower("player", 0) > 5000, UnitAffectingCombat("player"), GetComboPoints("player", "target") >= 5 } local count = 0 for _, met in ipairs(criteria) do if met then count = count + 1 end end return count >= 3 // At least 3 criteria metend