WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Hiding buffs/debuffs on target/focus frame (https://www.wowinterface.com/forums/showthread.php?t=56473)

plopek 07-29-18 07:08 PM

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

myrroddin 07-29-18 09:42 PM

Why don't you UnregisterUnitEvent("UNIT_AURA", "target")?

plopek 07-30-18 04:14 AM

I have no programming knowledge could you tell me how to use it?

myrroddin 07-30-18 06:40 AM

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")

plopek 07-30-18 06:57 AM

Sadly it doesn't work:( It doesn't hide buffs/debuffs nor throwing errors. Do you have any idea what could be wrong?

runamonk 07-30-18 08:09 AM

HideBuffs

It's discontinued but it works just fine. I just tested it out.

plopek 07-30-18 09:10 AM

Quote:

Originally Posted by runamonk (Post 329188)
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"

runamonk 07-30-18 09:16 AM

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)

plopek 07-30-18 09:58 AM

Works! Thank you for that:banana:

runamonk 07-30-18 10:45 AM

This is a terrible way to do it but it'll work for now hehe.

Ammako 07-30-18 01:14 PM

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.

jeruku 07-30-18 04:11 PM

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

Vrul 07-30-18 04:37 PM

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)


runamonk 07-31-18 04:11 AM

^=== this is a much more elegant and friendly way to do it. :)


All times are GMT -6. The time now is 12:21 PM.

vBulletin © 2021, Jelsoft Enterprises Ltd
© 2004 - 2020 MMOUI