mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-03-22 23:30:14 +00:00
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:
parent
ee3f60a1bb
commit
0a62529b55
1 changed files with 15 additions and 0 deletions
|
|
@ -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 ----
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue