Thread Tools Display Modes
04-02-12, 08:15 PM   #1
Doskious
A Deviate Faerie Dragon
AddOn Author - Click to view addons
Join Date: Mar 2009
Posts: 14
Question Chat channel initialization?

I'm looking for functionality that will allow me to define a chat channel other than "/say" as the chat channel that comes up by default when opening chat after immediately logging into the game.

I use Prat, and I enjoy the highly customizable sticky-channel functionality it offers, but immediately after I've logged in and I hit the enter button to type something, the default chat channel for that initial message defaults to /say, when I'd rather it were /guild or something else.

I've used a number of different chat mods over the years I've been playing, and at least one of them used to provide this functionality. Sadly, none of the mods I've tried now seem to be able to address this need, and I've forgotten which mod it was that did this.

Any help would be appreciated. (Minor, but frustrating.)

~Doskious Steele
  Reply With Quote
04-02-12, 09:19 PM   #2
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Something like this should work:
Code:
local function apply(editBox)
	editBox:SetAttribute("chatType", "GUILD")
	editBox:SetAttribute("stickyType", "GUILD")
end

-- apply change to all existing chat frames
for i = 1, 10 do
	local editBox = _G["ChatFrame"..i.."EditBox"]
	if editBox then
		apply(editBox)
	end
end

-- apply change to all future chat frames when they are created
hooksecurefunc(ChatEdit_OnLoad, apply)
  Reply With Quote
04-02-12, 09:47 PM   #3
Doskious
A Deviate Faerie Dragon
AddOn Author - Click to view addons
Join Date: Mar 2009
Posts: 14
Originally Posted by Phanx View Post
Something like this should work:
Code:
local function apply(editBox)
	editBox:SetAttribute("chatType", "GUILD")
	editBox:SetAttribute("stickyType", "GUILD")
end

-- apply change to all existing chat frames
for i = 1, 10 do
	local editBox = _G["ChatFrame"..i.."EditBox"]
	if editBox then
		apply(editBox)
	end
end

-- apply change to all future chat frames when they are created
hooksecurefunc(ChatEdit_OnLoad, apply)
Yes, rather. Erm. I follow that code -- what do I do with it? ^_^;

Armed with this reply, I was able to track down the chat mod that I used that provided this functionality - it was Cirk's ChatManager, accomplished with a slightly more robust (at that time) bit of code, to support D/Cs when grouped, raiding, PvPing, etc. I've attempted to produce something similar:

Code:
local function apply(editBox)
    if ((IsInInstance() == "pvp") and (GetNumRaidMembers() > 0)) then
        editBox:SetAttribute("chatType", "BATTLEGROUND");
        editBox:SetAttribute("stickyType", "BATTLEGROUND");
    elseif (GetNumRaidMembers() > 0) then
        editBox:SetAttribute("chatType", "RAID");
        editBox:SetAttribute("stickyType", "RAID");
    elseif (GetNumPartyMembers() > 0) then
        editBox:SetAttribute("chatType", "PARTY");
        editBox:SetAttribute("stickyType", "PARTY");
    elseif IsInGuild() then
        editBox:SetAttribute("chatType", "GUILD");
        editBox:SetAttribute("stickyType", "GUILD");
    end
end

-- apply change to all existing chat frames
for i = 1, 10 do
	local editBox = _G["ChatFrame"..i.."EditBox"]
	if editBox then
		apply(editBox)
	end
end

-- apply change to all future chat frames when they are created
hooksecurefunc(ChatEdit_OnLoad, apply)
Would this code provide initial chat channel selection based on login conditions to support logging back in from a DC into a BG, raid, or party, followed by default guild support unless the chosen character is guildless wherein it will do nothing (leaving the default as SAY)?
  Reply With Quote
04-03-12, 01:08 AM   #4
Rilgamon
Premium Member
 
Rilgamon's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Sep 2009
Posts: 822
Looks good ... but IIRC you need to delay until "PLAYER_ENTERING_WORLD" has fired.


Lua Code:
  1. local f = CreateFrame("Frame")
  2. f:RegisterEvent("PLAYER_ENTERING_WORLD")
  3. f:SetScript("OnEvent", function(self,event)
  4. -- Your Code here --
  5. self:UnregisterEvent(event)
  6. end)
__________________
The cataclysm broke the world ... and the pandas could not fix it!
  Reply With Quote
04-03-12, 01:53 AM   #5
Doskious
A Deviate Faerie Dragon
AddOn Author - Click to view addons
Join Date: Mar 2009
Posts: 14
Originally Posted by Rilgamon View Post
Looks good ... but IIRC you need to delay until "PLAYER_ENTERING_WORLD" has fired.


Lua Code:
  1. local f = CreateFrame("Frame")
  2. f:RegisterEvent("PLAYER_ENTERING_WORLD")
  3. f:SetScript("OnEvent", function(self,event)
  4. -- Your Code here --
  5. self:UnregisterEvent(event)
  6. end)
That seems to have done it. (I had to eliminate the function call and process the If/elseif block inline, but it seems to work. Thanks very much for your help, both.

Publishing an AddOn is fun!
  Reply With Quote

WoWInterface » AddOns, Compilations, Macros » AddOn Search/Requests » Chat channel initialization?

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