Thread Tools Display Modes
08-17-24, 03:31 PM   #1
jlrm365
A Flamescale Wyrmkin
AddOn Author - Click to view addons
Join Date: Oct 2007
Posts: 118
Question Tweak to work

Hello.

Until recently, an addon called AntiCosmeticAuras existed on CurseForge.
It auto-removed cosmetic buffs / auras, out of combat.

It was removed a while back, but it still functioned.
With the most recent update, it stopped functioning.

Is there any part of this that can be tweaked, to revive it? If so, which?
Thanks!






-- GLOBAL VARIABLES

local anticosmeticaurasframe;



-- FUNCTIONS

function anticosmeticauras_OnEvent(this, event, ...)
if IsInInstance() then return end
for i=1, 40 do
local name = UnitBuff("player", i);

if (name == nil) then
return;
end

if (name == "A Witch!") then
CancelUnitBuff("player", i);
return;
end
end


end -- end onEvent



-- FRAME VARIABLES

-- Create the frame. Register the events that makes it activate, and set scripts on it such that it is good
anticosmeticaurasframe = CreateFrame("Frame", "anticosmeticaurasframe", UIParent);
anticosmeticaurasframe:SetScript("OnEvent", anticosmeticauras_OnEvent);

-- Register the events for the frame
anticosmeticaurasframe:RegisterEvent("UNIT_AURA"); -- Fires when a buff or debuff is either applied to or is removed from the player
  Reply With Quote
08-17-24, 04:13 PM   #2
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,974
Try:
Lua Code:
  1. local function anticosmeticauras_OnEvent(this, event, ...)
  2.     if IsInInstance() then
  3.         return
  4.     end
  5.     local auraData = C_UnitAuras.GetAuraDataBySpellName("player", "A Witch!")
  6.     if auraData and not InCombatLockdown() then
  7.         CancelSpellByName("A Witch!")
  8.     end
  9. end -- end onEvent
  10. local f = CreateFrame("Frame", "anticosmeticaurasframe", UIParent);
  11. f:SetScript("OnEvent", anticosmeticauras_OnEvent);
  12. f:RegisterEvent("UNIT_AURA"); -- Fires when a buff or debuff is either applied to or is removed from the player
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.
  Reply With Quote
08-17-24, 04:36 PM   #3
jlrm365
A Flamescale Wyrmkin
AddOn Author - Click to view addons
Join Date: Oct 2007
Posts: 118
Originally Posted by Fizzlemizz View Post
Try:
Lua Code:
  1. local function anticosmeticauras_OnEvent(this, event, ...)
  2.     if IsInInstance() then
  3.         return
  4.     end
  5.     local auraData = C_UnitAuras.GetAuraDataBySpellName("player", "A Witch!")
  6.     if auraData and not InCombatLockdown() then
  7.         CancelSpellByName("A Witch!")
  8.     end
  9. end -- end onEvent
  10. local f = CreateFrame("Frame", "anticosmeticaurasframe", UIParent);
  11. f:SetScript("OnEvent", anticosmeticauras_OnEvent);
  12. f:RegisterEvent("UNIT_AURA"); -- Fires when a buff or debuff is either applied to or is removed from the player

Wonderful.
I must remember to enter buff names twice, instead of once - as was habit, but that's very slick.
Thanks!
  Reply With Quote
08-17-24, 04:42 PM   #4
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,974
Create a table of aura names to check/cancel"
Lua Code:
  1. local CancelAuras = { -- add aruas to cancel to the list
  2.     "A Witch!",
  3.     "Arcane Intellect",
  4.     "And Another One",
  5. }
  6. local function anticosmeticauras_OnEvent(this, event, ...)
  7.     if IsInInstance() then
  8.         return
  9.     end
  10.     for _, aura in pairs(CancelAuras) do
  11.         local auraData = C_UnitAuras.GetAuraDataBySpellName("player", aura)
  12.         if auraData then
  13.             CancelSpellByName(aura)
  14.         end
  15.     end
  16. end -- end onEvent
  17. local f = CreateFrame("Frame", "anticosmeticaurasframe", UIParent);
  18. f:SetScript("OnEvent", anticosmeticauras_OnEvent);
  19. f:RegisterEvent("UNIT_AURA"); -- Fires when a buff or debuff is either applied to or is removed from the player
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 08-17-24 at 04:45 PM.
  Reply With Quote
08-17-24, 04:44 PM   #5
jlrm365
A Flamescale Wyrmkin
AddOn Author - Click to view addons
Join Date: Oct 2007
Posts: 118
Originally Posted by Fizzlemizz View Post
Create a table of aura names to check/cancel"
Lua Code:
  1. local CancelAuras = { -- add aruas to cancel to the list
  2.     "A Witch!",
  3.     "Something else",
  4.     "And Another One",
  5. }
  6. local function anticosmeticauras_OnEvent(this, event, ...)
  7.     if IsInInstance() then
  8.         return
  9.     end
  10.     for _, aura in pairs(CancelAuras) do
  11.         local auraData = C_UnitAuras.GetAuraDataBySpellName(aura)
  12.         if auraData then
  13.             CancelSpellByName(aura)
  14.         end
  15.     end
  16. end -- end onEvent
  17. local f = CreateFrame("Frame", "anticosmeticaurasframe", UIParent);
  18. f:SetScript("OnEvent", anticosmeticauras_OnEvent);
  19. f:RegisterEvent("UNIT_AURA"); -- Fires when a buff or debuff is either applied to or is removed from the player
Better than the original.
Very much appreciated.
  Reply With Quote
08-17-24, 04:46 PM   #6
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,974
Left the unit name off the C_UnitAuras.GetAuraDataBySpellName call, fixed in the post above.
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.
  Reply With Quote
08-17-24, 11:02 PM   #7
jlrm365
A Flamescale Wyrmkin
AddOn Author - Click to view addons
Join Date: Oct 2007
Posts: 118
Originally Posted by Fizzlemizz View Post
Left the unit name off the C_UnitAuras.GetAuraDataBySpellName call, fixed in the post above.
Yup.
Added in my extra auras and it does the job.
I'd say your solution improves on the original, with the list as it is and the ability to tweak the LUA so easily.
Thanks again!
  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » Tweak to work


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off