Hi, i need some help. i want to hide the buff and debuffs on target and focus default blizzard frames.
for that i use this code:
UIParent:SetScript("OnUpdate", function()
if TargetFrame:IsShown() then
numBuffs = 0
for i=1, MAX_TARGET_BUFFS do
if( select(3, UnitBuff("target", i)) ) then
numBuffs = numBuffs + 1
end
end
numDebuffs = 0
for i=1, MAX_TARGET_DEBUFFS do
if( select(3, UnitDebuff("target", i)) ) then
numDebuffs = numDebuffs + 1
end
end
for i=1, numBuffs do
local frame = _G["TargetFrameBuff"..i]
frame:Hide()
end
for i=1, numDebuffs do
local frame = _G["TargetFrameDebuff"..i]
frame:Hide()
end
end
if FocusFrame:IsShown() then
numDebuffs = 0
for i=1, MAX_FOCUS_DEBUFFS do
if( select(3, UnitDebuff("focus", i)) ) then
numDebuffs = numDebuffs + 1
end
end
for i=1, numDebuffs do
local frame = _G["FocusFrameDebuff"..i]
frame:Hide()
end
end
end)
the code works for the target frame very well, but not for the focus frame.
when i set a focus i get follow .lua errors.
Message: Interface\AddOns\xxx\unitframes.lua:127: 'for' limit must be a number
Time: 08/05/11 13:55:31
Count: 1618
Stack: Interface\AddOns\xxx\unitframes.lua:127: in function <Interface\AddOns\xxx\unitframes.lua:99>
Locals: (for index) = 1
(for limit) = nil
(for step) = 1
(*temporary) = 5
(*temporary) = TargetFrameDebuff5 {
0 = <userdata>
unit = "target"
}
(*temporary) = <function> defined =[C]:-1
(*temporary) = TargetFrameDebuff5 {
0 = <userdata>
unit = "target"
}
(*temporary) = <userdata>
(*temporary) = 16
(*temporary) = "'for' limit must be a number"
First, why are you changing OnUpdate for UIParent, what if something else is using it?
Why numBuffs and numDebuffs aren't locals?
It would help if you mentioned which exact line was giving problems, since "line 127" doesn't say much if we don't have the whole file.
Edit: bah ninja
/dump MAX_FOCUS_DEBUFFS returns nil for me, while the other two globals you use return integers. This strikes me as odd, though, as it looks like a global variable is set on line 1 of FocusFrame.lua?
The error message line number doesn't match the code. Either post the full code or tell us which line is line 127.
That said, make sure the variable you are using in the for loop on line 127 is not nil.
sry, it says line 127 because i put the code into my unitframes.lua. this file has some codes. i use some arenajunkies codes, because i play with default ui.
/dump MAX_FOCUS_DEBUFFS returns nil for me, while the other two globals you use return integers. This strikes me as odd, though, as it looks like a global variable is set on line 1 of FocusFrame.lua?
i have a last qusetion. why does this small code have such a high CPU Cycle?
Because it works now and your code is running every time the screen refreshes. Meaning that if you're getting 50 FPS, your code is running 50 times per second.
You don't need to hide them on every frame, and especially don't change OnUpdate of UIParent - who knows what it might be needed for.
Usually what's done is the unneeded elements are hidden once, and their OnShow handler is changed to re-hide them.
To add to that: if you must use an existing frame's script handler, use :HookScript() instead of :SetScript(). Even if you know Blizzard isn't using it. That is unless you are completely replacing the whole script handler with your own and are taking any Blizzard activity into account. For example: the FriendsFrame populates the friend list OnShow and you want to change that so it shows a differently styled friends list instead.
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
for that i use this code:
the code works for the target frame very well, but not for the focus frame.
when i set a focus i get follow .lua errors.
That said, make sure the variable you are using in the for loop on line 127 is not nil.
Why numBuffs and numDebuffs aren't locals?
It would help if you mentioned which exact line was giving problems, since "line 127" doesn't say much if we don't have the whole file.
Edit: bah ninja
its not a addon, i use just some codes. i play with default ui.
sry, it says line 127 because i put the code into my unitframes.lua. this file has some codes. i use some arenajunkies codes, because i play with default ui.
what exactly i need to do?
Thank you very much, it helps me alot.
Because it works now and your code is running every time the screen refreshes. Meaning that if you're getting 50 FPS, your code is running 50 times per second.
Usually what's done is the unneeded elements are hidden once, and their OnShow handler is changed to re-hide them.