If you want to simply use a player's existing chat tabs, here's some relevant info:
The first object returned by GetChatWindowInfo(index) is the name of the tab, so GetChatWindowInfo(1) will return "General" in the vast majority of clients. Index is the same number of ChatFrame, so General is ChatFrame1 and the Combat Log is ChatFrame2.
Here's what I use in my addon:
Code:
local notfound,c=true,ChatTypeInfo.SYSTEM
for i=1,NUM_CHAT_WINDOWS do if _G['ChatFrame'..i]:IsEventRegistered('CHAT_MSG_SYSTEM') then
notfound=false
_G['ChatFrame'..i]:AddMessage(message,c.r,c.g,c.b,c.id)
end end
if notfound then DEFAULT_CHAT_FRAME:AddMessage(message,c.r,c.g,c.b,c.id) end
This copies the data used by the yellow system messages and then prints to any window registered to handle system messages. If there are no windows that show system messages, it prints to whatever window is the default one.
If someone were to create a chatframe named "addonlog" and wanted the above code to print to that, you would do this:
Code:
local notfound,c=true,ChatTypeInfo.SYSTEM
for i=1,NUM_CHAT_WINDOWS do if GetChatWindowInfo(i)=='addonlog' then
notfound=false
_G['ChatFrame'..i]:AddMessage(message,c.r,c.g,c.b,c.id)
end end
if notfound then DEFAULT_CHAT_FRAME:AddMessage(message,c.r,c.g,c.b,c.id) end
If you wanted to save the log between sessions while still keeping it in the chatframe, you can save every message into a table, save that table in a SavedVariable, and then loop through it in order and dump it to the chatframe every time the UI is loaded.