Thread Tools Display Modes
11-30-19, 09:40 AM   #1
cokedrivers
A Rage Talon Dragon Guard
 
cokedrivers's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2009
Posts: 325
Changeing Chat Bubble Name Color

Hello I have been trying to figure this out for a while now, I have the names able to do RAID_CLASS_COLORS or a specific color but how do I get them to do the reaction color to me, so an enemy's NPC name will show up red.

Here is the current code im working with:
Lua Code:
  1. local events = {
  2.             CHAT_MSG_SAY = 'chatBubbles',
  3.             CHAT_MSG_YELL = 'chatBubbles',
  4.             CHAT_MSG_PARTY = 'chatBubblesParty',
  5.             CHAT_MSG_PARTY_LEADER = 'chatBubblesParty',
  6.             CHAT_MSG_MONSTER_SAY = 'chatBubbles',
  7.             CHAT_MSG_MONSTER_YELL = 'chatBubbles',
  8.             CHAT_MSG_MONSTER_PARTY = 'chatBubblesParty',
  9.         }
  10.  
  11.         local function SkinFrame(frame)
  12.             for i = 1, select('#', frame:GetRegions()) do
  13.                 local region = select(i, frame:GetRegions())
  14.                 if (region:GetObjectType() == 'FontString') then
  15.                     frame.text = region
  16.                 else
  17.                     region:Hide()
  18.                 end
  19.             end
  20.  
  21.             frame.text:SetFontObject('SystemFont_Tiny')
  22.             frame.text:SetJustifyH('LEFT')
  23.  
  24.             frame:ClearAllPoints()
  25.             frame:SetPoint('TOPLEFT', frame.text, -10, 25)
  26.             frame:SetPoint('BOTTOMRIGHT', frame.text, 10, -10)
  27.             frame:SetBackdrop({
  28.                 bgFile = [[Interface\DialogFrame\UI-DialogBox-Background-Dark]],
  29.                 edgeFile = [[Interface\Tooltips\UI-Tooltip-Border]],
  30.                 tile = true, tileSize = 16, edgeSize = 18,
  31.                 insets = {left = 3, right = 3, top = 3, bottom = 3}
  32.             })
  33.             frame:SetBackdropColor(0, 0, 0, 1)
  34.             local r, g, b = frame.text:GetTextColor()
  35.             frame:SetBackdropBorderColor(r, g, b, .8)
  36.  
  37.             frame.sender = frame:CreateFontString(nil, 'OVERLAY', 'GameFontNormalSmall')
  38.             frame.sender:SetPoint('BOTTOMLEFT', frame.text, 'TOPLEFT', 0, 4)
  39.             frame.sender:SetJustifyH('LEFT')
  40.  
  41.             frame:HookScript('OnHide', function()
  42.                 frame.inUse = false
  43.             end)
  44.         end
  45.  
  46.         local function UpdateFrame(frame, guid, name)
  47.             if (not frame.text) then
  48.                 SkinFrame(frame)
  49.             end
  50.             frame.inUse = true
  51.  
  52.             local ccolor
  53.             if (guid ~= nil and guid ~= '') then
  54.                 _, ccolor, _, _, _, _ = GetPlayerInfoByGUID(guid)
  55.             end
  56.  
  57.             if (name) then
  58.                 local color = RAID_CLASS_COLORS[ccolor] or {r = 1, g = 1, b = 0}
  59.                 frame.sender:SetText(('|cFF%2x%2x%2x%s|r'):format(color.r * 255, color.g * 255, color.b * 255, name))
  60.                 if frame.text:GetWidth() < frame.sender:GetWidth() then
  61.                     frame.text:SetWidth(frame.sender:GetWidth())
  62.                 end
  63.             end
  64.         end
  65.  
  66.         local function FindFrame(msg)
  67.             for i = 1, WorldFrame:GetNumChildren() do
  68.                 local frame = select(i, WorldFrame:GetChildren())
  69.                 if (not frame:GetName() and not frame.inUse) then
  70.                     for i = 1, select('#', frame:GetRegions()) do
  71.                         local region = select(i, frame:GetRegions())
  72.                         if region:GetObjectType() == 'FontString' and region:GetText() == msg then
  73.                             return frame
  74.                         end
  75.                     end
  76.                 end
  77.             end
  78.         end
  79.  
  80.         local ChatBubbleFrame = CreateFrame('Frame')
  81.         for event, cvar in pairs(events) do
  82.             ChatBubbleFrame:RegisterEvent(event)
  83.         end
  84.  
  85.         ChatBubbleFrame:SetScript('OnEvent', function(self, event, msg, sender, _, _, _, _, _, _, _, _, _, guid)
  86.             if (GetCVarBool(events[event])) then
  87.                 ChatBubbleFrame.elapsed = 0
  88.                 ChatBubbleFrame:SetScript('OnUpdate', function(self, elapsed)
  89.                     self.elapsed = self.elapsed + elapsed
  90.                     local frame = FindFrame(msg)
  91.                     if (frame or self.elapsed > 0.3) then
  92.                         ChatBubbleFrame:SetScript('OnUpdate', nil)
  93.                         if (frame) then
  94.                             UpdateFrame(frame, guid, sender)
  95.                         end
  96.                     end
  97.                 end)
  98.             end
  99.         end)
  100.     end
I know its in the
Code:
if (name)
part of the code but I cant seem to figure out how to get it to use recation color.

Thanks for any help with this.
Coke
  Reply With Quote
11-30-19, 01:23 PM   #2
myrroddin
A Pyroguard Emberseer
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 1,240
You need two things:
  1. https://wow.gamepedia.com/API_UnitReaction in which case the unitID ("player") and the unitID of the comparison.
  2. The global table FACTION_BAR_COLORS in which to pass the reaction number above.

Lua Code:
  1. local reaction = UnitReaction("target", "player")
  2. local reactionColor = FACTION_BAR_COLORS[reaction]
  Reply With Quote
12-01-19, 07:22 AM   #3
cokedrivers
A Rage Talon Dragon Guard
 
cokedrivers's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2009
Posts: 325
Originally Posted by myrroddin View Post
You need two things:
  1. https://wow.gamepedia.com/API_UnitReaction in which case the unitID ("player") and the unitID of the comparison.
  2. The global table FACTION_BAR_COLORS in which to pass the reaction number above.

Lua Code:
  1. local reaction = UnitReaction("target", "player")
  2. local reactionColor = FACTION_BAR_COLORS[reaction]
Thanks for the code.
I ended up using it like below and it works fine:
Lua Code:
  1. local reaction = UnitReaction("target", "player")          
  2. local color = CUSTOM_FACTION_BAR_COLORS[reaction] or RAID_CLASS_COLORS[ccolor] or {r = 1, g = 1, b = 0}

So thanks again.
Coke
  Reply With Quote
12-01-19, 11:33 AM   #4
myrroddin
A Pyroguard Emberseer
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 1,240
At the top of the addon file, I'd give users the options of custom or default colour schemes.
Lua Code:
  1. local CUSTOM_FACTION_BAR_COLORS = CUSTOM_FACTION_BAR_COLORS or FACTION_BAR_COLORS
  2. local CUSTOM_CLASS_COLORS = CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS

Class Colors, Curseforge: https://www.curseforge.com/wow/addons/classcolors
Class Colors, Wowinterface: https://www.wowinterface.com/downloa...assColors.html

Documentation: https://github.com/phanx-wow/ClassColors/wiki

Obviously CUSTOM_FACTION_BAR_COLORS is unique to your addon but you could still provide some options.
  Reply With Quote
12-07-19, 07:31 AM   #5
cokedrivers
A Rage Talon Dragon Guard
 
cokedrivers's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2009
Posts: 325
Originally Posted by myrroddin View Post
At the top of the addon file, I'd give users the options of custom or default colour schemes.
Lua Code:
  1. local CUSTOM_FACTION_BAR_COLORS = CUSTOM_FACTION_BAR_COLORS or FACTION_BAR_COLORS
  2. local CUSTOM_CLASS_COLORS = CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS

Class Colors, Curseforge: https://www.curseforge.com/wow/addons/classcolors
Class Colors, Wowinterface: https://www.wowinterface.com/downloa...assColors.html

Documentation: https://github.com/phanx-wow/ClassColors/wiki

Obviously CUSTOM_FACTION_BAR_COLORS is unique to your addon but you could still provide some options.
Thanks, I have not published a addon sence the launch of BFA its mostly all for my use but thank you for the option.

Coke
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Changeing Chat Bubble Name Color

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