Thread Tools Display Modes
07-15-12, 12:19 PM   #1
Caetan0
A Warpwood Thunder Caller
Join Date: Aug 2011
Posts: 99
help [addon chat]

friends,
I have this addon that whenever I go into combat, the windows of the minimap and chat are invisible.
Code:
local HiC = CreateFrame("Frame", "HiC", UIParent)
function HiC.OnEvent(self, event)
	if event == "PLAYER_REGEN_DISABLED" then
		GeneralDockManager:Hide()
		DEFAULT_CHAT_FRAME:Hide()
		FriendsMicroButton:Hide()
		ChatFrameMenuButton:Hide()
		MinimapCluster:Hide()
	else
		GeneralDockManager:Show()
		DEFAULT_CHAT_FRAME:Show()
		FriendsMicroButton:Show()
		ChatFrameMenuButton:Show()
		MinimapCluster:Show()
	end
end
HiC:SetScript("OnEvent", HiC.OnEvent)
HiC:RegisterEvent("PLAYER_REGEN_ENABLED")
HiC:RegisterEvent("PLAYER_REGEN_DISABLED")
The problem is that often, when I go into combat, the chat window remains visible, Would anyone know what might be?
  Reply With Quote
07-17-12, 03:55 AM   #2
Caetan0
A Warpwood Thunder Caller
Join Date: Aug 2011
Posts: 99
someone has any idea of why this occurred
  Reply With Quote
07-17-12, 04:22 AM   #3
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
Are you sure that you do not get any "Addon blocked message?"

If so you got a taint and the addon action is blocked. Show/Hide is prohibited for certain Blizzard frames in combat. You can change that by using secure methods.

Lua Code:
  1. RegisterStateDriver(MinimapCluster, "visibility", "[combat] hide;show")
__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW)

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)
  Reply With Quote
07-17-12, 06:28 PM   #4
Caetan0
A Warpwood Thunder Caller
Join Date: Aug 2011
Posts: 99
Friend, I used the code that you sent and it has worked bwem, however, when the map loads into a new scenario, I have to enter all the codes again.

The solution I found was this, see if this could be good or better?

Code:
local combate = 0
local function onUpdate(self,elapsed)
    combate = combate + elapsed
    if combate >= 0 then
        RegisterStateDriver(GeneralDockManager, "visibility", "[combat] hide;show")
        RegisterStateDriver(DEFAULT_CHAT_FRAME, "visibility", "[combat] hide;show")
        RegisterStateDriver(FriendsMicroButton, "visibility", "[combat] hide;show")
        RegisterStateDriver(ChatFrameMenuButton, "visibility", "[combat] hide;show")
        RegisterStateDriver(MinimapCluster, "visibility", "[combat] hide;show")
        RegisterStateDriver(ChatFrame4, "visibility", "[combat] hide;show")
        combate = 0
    end
local f = CreateFrame("frame")
f:SetScript("OnUpdate", onUpdate)
  Reply With Quote
07-18-12, 08:12 AM   #5
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
OnUpdate fires on every single frame the game is drawing. You run your function 200times a second on 200fps.

Not sure what you are trying to do and why you are rewriting the state driver all the time.
The state driver runs every 0.2 seconds. Frames will hide automatically after 0.2 seconds again.

Btw have you tried this?
Lua Code:
  1. local frame = CreateFrame("Frame","myFrameHider")
  2. RegisterStateDriver(frame, "visibility", "[combat] hide;show")
  3. GeneralDockManager:SetParent(frame)
  4. FriendsMicroButton:SetParent(frame)
  5. ChatFrame1:SetParent(frame)
  6. ChatFrameMenuButton:SetParent(frame)
  7. MinimapCluster:SetParent(frame)
  8. ChatFrame4:SetParent(frame)

This reparents your frames and adds the statedriver to the parent frame.
__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW)

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)
  Reply With Quote
07-18-12, 02:15 PM   #6
Caetan0
A Warpwood Thunder Caller
Join Date: Aug 2011
Posts: 99
did not work
  Reply With Quote
07-22-12, 02:54 AM   #7
Aanson
A Flamescale Wyrmkin
Join Date: Aug 2009
Posts: 124
Originally Posted by Caetan0 View Post
friends,
I have this addon that whenever I go into combat, the windows of the minimap and chat are invisible.
Code:
local HiC = CreateFrame("Frame", "HiC", UIParent)
function HiC.OnEvent(self, event)
	if event == "PLAYER_REGEN_DISABLED" then
		GeneralDockManager:Hide()
		DEFAULT_CHAT_FRAME:Hide()
		FriendsMicroButton:Hide()
		ChatFrameMenuButton:Hide()
		MinimapCluster:Hide()
	else
		GeneralDockManager:Show()
		DEFAULT_CHAT_FRAME:Show()
		FriendsMicroButton:Show()
		ChatFrameMenuButton:Show()
		MinimapCluster:Show()
	end
end
HiC:SetScript("OnEvent", HiC.OnEvent)
HiC:RegisterEvent("PLAYER_REGEN_ENABLED")
HiC:RegisterEvent("PLAYER_REGEN_DISABLED")
The problem is that often, when I go into combat, the chat window remains visible, Would anyone know what might be?

This should work, as other chat frames (ie ChatFrame2 etc) seem to inherit their behavior from ChatFrame1. Although, I'm pretty sure that FriendsMicroButton and ChatFrameMenuButton are parented to ChatFrame1 anyway, so you can probably remove the lines for them:

Lua Code:
  1. local HiC = CreateFrame("Frame", "HiC", UIParent)
  2. function HiC.OnEvent(self, event)
  3.     if event == "PLAYER_REGEN_DISABLED" then
  4.         GeneralDockManager:Hide()
  5.         ChatFrame1:Hide()
  6.         MinimapCluster:Hide()
  7.     else
  8.         GeneralDockManager:Show()
  9.         ChatFrame1:Show()
  10.         MinimapCluster:Show()
  11.     end
  12. end
  13. HiC:SetScript("OnEvent", HiC.OnEvent)
  14. HiC:RegisterEvent("PLAYER_REGEN_ENABLED")
  15. HiC:RegisterEvent("PLAYER_REGEN_DISABLED")

From what I've learned about OnUpdate, you should try and always use a counter, but if you're checking that the counter >= 0.0 (or that the counter is more than or equal to zero) then it may as well not exist.

If ever you are tempted to use OnUpdate, I suggest that you change you're line to:

Lua Code:
  1. combate = combate + elapsed
  2. if combate >= 1 then
  3.   -- input your code
  4.   combate = 0  -- reset your counter to 0 after your code has been input
  5. end

That way, your OnUpdate code will only be read once per second as opposed to 60 times per second (with a frame rate of 60).
__________________
__________________
  Reply With Quote

WoWInterface » AddOns, Compilations, Macros » AddOn Help/Support » help [addon chat]


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