Quantcast
Hiding buffs/debuffs on target/focus frame - WoWInterface
Thread Tools Display Modes
07-29-18, 07:08 PM   #1
plopek
A Deviate Faerie Dragon
AddOn Compiler - Click to view compilations
Join Date: Aug 2014
Posts: 15
Hiding buffs/debuffs on target/focus frame

Hi,
So I have this script which allows me to hide all buffs and debuffs from mentioned in the title frames but unfortunately its tainting. Could someone help me to make it work?
Lua Code:
  1. --hides default target/focus buffs/debuffs
  2.         TargetFrame.maxBuffs = 0
  3.         TargetFrame.maxDebuffs = 0
  4.         MAX_TARGET_BUFFS = 0
  5.         MAX_TARGET_DEBUFFS = 0
  6.         TargetFrame_UpdateAuras(TargetFrame)
  7.        
  8.         if FocusFrame:IsShown() then
  9.         FocusFrame.maxBuffs = 0
  10.         FocusFrame.maxDebuffs = 0
  11.         MAX_FOCUS_BUFFS = 0
  12.         MAX_FOCUS_DEBUFFS = 0
  13.         FocusFrame_UpdateAuras(FocusFrame)
  14.         end
  Reply With Quote
07-29-18, 09:42 PM   #2
myrroddin
A Pyroguard Emberseer
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 1,124
Why don't you UnregisterUnitEvent("UNIT_AURA", "target")?
  Reply With Quote
07-30-18, 04:14 AM   #3
plopek
A Deviate Faerie Dragon
AddOn Compiler - Click to view compilations
Join Date: Aug 2014
Posts: 15
I have no programming knowledge could you tell me how to use it?
  Reply With Quote
07-30-18, 06:40 AM   #4
myrroddin
A Pyroguard Emberseer
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 1,124
Should be as simple as the following. I did I typo in my earlier post.
Lua Code:
  1. TargetFrame:UnregisterEvent("UNIT_AURA")
  2. FocusFrame:UnregisterEvent("UNIT_AURA")
  Reply With Quote
07-30-18, 06:57 AM   #5
plopek
A Deviate Faerie Dragon
AddOn Compiler - Click to view compilations
Join Date: Aug 2014
Posts: 15
Sadly it doesn't work It doesn't hide buffs/debuffs nor throwing errors. Do you have any idea what could be wrong?
  Reply With Quote
07-30-18, 08:09 AM   #6
runamonk
A Wyrmkin Dreamwalker
 
runamonk's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2007
Posts: 57
HideBuffs

It's discontinued but it works just fine. I just tested it out.
  Reply With Quote
07-30-18, 09:10 AM   #7
plopek
A Deviate Faerie Dragon
AddOn Compiler - Click to view compilations
Join Date: Aug 2014
Posts: 15
Originally Posted by runamonk View Post
HideBuffs

It's discontinued but it works just fine. I just tested it out.
That's great alternative but there is one problem as soon as I add focus target it throws errors
Lua Code:
  1. 25x HideBuffs\HideBuffs-0.01a.lua:29: 'for' limit must be a number
  2. HideBuffs\HideBuffs-0.01a.lua:29: in function <HideBuffs\HideBuffs.lua:1>
  3.  
  4. Locals:
  5. (for index) = 1
  6. (for limit) = nil
  7. (for step) = 1
  8. (*temporary) = 2
  9. (*temporary) = TargetFrameBuff2 {
  10.  0 = <userdata>
  11.  unit = "target"
  12. }
  13. (*temporary) = <function> defined =[C]:-1
  14. (*temporary) = TargetFrameBuff2 {
  15.  0 = <userdata>
  16.  unit = "target"
  17. }
  18. (*temporary) = <userdata>
  19. (*temporary) = 16
  20. (*temporary) = "'for' limit must be a number"
  Reply With Quote
07-30-18, 09:16 AM   #8
runamonk
A Wyrmkin Dreamwalker
 
runamonk's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2007
Posts: 57
Checking...this looks simple enough.

Paste this code over the top of the code in the HideBuffs.lua

Lua Code:
  1. UIParent:SetScript("OnUpdate", function()
  2.     if TargetFrame:IsShown() then
  3.         for i=1, MAX_TARGET_BUFFS do
  4.             local frame = _G["TargetFrameBuff"..i]
  5.             if frame ~= nil then frame:Hide() end
  6.         end
  7.  
  8.         for i=1, MAX_TARGET_DEBUFFS do
  9.             local frame = _G["TargetFrameDebuff"..i]
  10.             if frame ~= nil then frame:Hide() end
  11.         end
  12.     end
  13.  
  14.     if FocusFrame:IsShown() then
  15.         numDebuffs = 0
  16.         for i=1, MAX_TARGET_BUFFS do
  17.             local frame = _G["FocusFrameBuff"..i]
  18.             if frame ~= nil then frame:Hide() end
  19.         end
  20.         for i=1, MAX_TARGET_DEBUFFS do
  21.             local frame = _G["FocusFrameDebuff"..i]
  22.             if frame ~= nil then frame:Hide() end
  23.         end
  24.     end
  25. end)

Last edited by runamonk : 07-30-18 at 09:30 AM.
  Reply With Quote
07-30-18, 09:58 AM   #9
plopek
A Deviate Faerie Dragon
AddOn Compiler - Click to view compilations
Join Date: Aug 2014
Posts: 15
Thumbs up

Works! Thank you for that
  Reply With Quote
07-30-18, 10:45 AM   #10
runamonk
A Wyrmkin Dreamwalker
 
runamonk's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2007
Posts: 57
This is a terrible way to do it but it'll work for now hehe.
  Reply With Quote
07-30-18, 01:14 PM   #11
Ammako
A Frostmaul Preserver
AddOn Author - Click to view addons
Join Date: Jun 2016
Posts: 256
Won't UIParent:SetScript("OnUpdate") just overwrite all of this, along with causing taint? HookScript is to be preferred over SetScript imo.

Of course, I say preferred very loosely given the code being used here, but you know. One step at a time.
  Reply With Quote
07-30-18, 04:11 PM   #12
jeruku
A Cobalt Mageweaver
 
jeruku's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2010
Posts: 218
A safe way to help prevent taint and keep UIParent working as intended.

Lua Code:
  1. local OnShow = function(frame)
  2.    frame:Hide()
  3. end
  4.  
  5. local list = {"TargetFrameBuff", "TargetFrameDebuff", "FocusFrameBuff", "FocusFrameDebuff"}
  6.  
  7. local aura, frame
  8. for x=1, #list do
  9.    frame = list[x]
  10.    for i=1, MAX_TARGET_BUFFS do
  11.       aura = _G[frame..i]
  12.       if aura then aura:HookScript('OnShow', OnShow) end
  13.    end
  14. end
__________________
"I have not failed, I simply found 10,000 ways that did not work." - Thomas Edison

Last edited by jeruku : 07-31-18 at 07:10 AM. Reason: Typo... I'd be a great at this if it wasn't for typos.
  Reply With Quote
07-30-18, 04:37 PM   #13
Vrul
An Onyxian Warder
 
Vrul's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2007
Posts: 368
You shouldn't mess with UIParent's OnUpdate script like Ammako pointed out. Try this:
Code:
TargetFrame:UnregisterEvent("UNIT_AURA")
FocusFrame:UnregisterEvent("UNIT_AURA")

hooksecurefunc("TargetFrame_UpdateAuras", function(frame)
    if frame ~= TargetFrame and frame ~= FocusFrame then return end

    local frameName = frame:GetName()

    for index = 1, MAX_TARGET_BUFFS do
        local buff = _G[frameName .. "Buff" .. index]
        if buff then
            buff:Hide()
        end
    end

    for index = 1, MAX_TARGET_DEBUFFS do
        local debuff = _G[frameName .. "Debuff" .. index]
        if debuff then
            debuff:Hide()
        end
    end
end)
  Reply With Quote
07-31-18, 04:11 AM   #14
runamonk
A Wyrmkin Dreamwalker
 
runamonk's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2007
Posts: 57
^=== this is a much more elegant and friendly way to do it.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Hiding buffs/debuffs on target/focus frame

Thread Tools
Display Modes

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