feat: add DEFAULT_CHAT_FRAME with AddMessage for addon output

Many WoW addons use DEFAULT_CHAT_FRAME:AddMessage(text, r, g, b) to
output colored text to chat. Implemented as a Lua table with AddMessage
that converts RGB floats to WoW color codes and calls print().
Also aliased as ChatFrame1 for compatibility.

Example: DEFAULT_CHAT_FRAME:AddMessage("Hello!", 1, 0.5, 0)
This commit is contained in:
Kelsi 2026-03-20 13:18:16 -07:00
parent ee3f60a1bb
commit 0a62529b55

View file

@ -917,6 +917,21 @@ void LuaEngine::registerCoreAPI() {
" return ticker\n"
"end\n"
);
// DEFAULT_CHAT_FRAME with AddMessage method (used by many addons)
luaL_dostring(L_,
"DEFAULT_CHAT_FRAME = {}\n"
"function DEFAULT_CHAT_FRAME:AddMessage(text, r, g, b)\n"
" if r and g and b then\n"
" local hex = format('|cff%02x%02x%02x', "
" math.floor(r*255), math.floor(g*255), math.floor(b*255))\n"
" print(hex .. tostring(text) .. '|r')\n"
" else\n"
" print(tostring(text))\n"
" end\n"
"end\n"
"ChatFrame1 = DEFAULT_CHAT_FRAME\n"
);
}
// ---- Event System ----