Thread Tools Display Modes
04-16-22, 03:50 PM   #1
escodashoota
A Defias Bandit
Join Date: Apr 2022
Posts: 2
Question Class Colored Names on Frames & No Background behind Name on Frames

Hello,

I'm trying to figure out a way I can create addons out of scripts from a addon I installed. When I use the addon however, it breaks other addons of mine which aren't very convenient. So I'd like to simply extract these two scripts from the addon; one gives Class Colours to names on the player & target frames, the other Removes the background behind the players name on the target frame.

Code for Class Coloured Names:
Lua Code:
  1. function RunClassColorsOnHealthBars()
  2. -- Включение цвета классов на полосах здоровья
  3. local UnitIsPlayer, UnitIsConnected, UnitClass, RAID_CLASS_COLORS = UnitIsPlayer, UnitIsConnected, UnitClass,
  4.     RAID_CLASS_COLORS
  5. local _, class, c
  6. local function colour(statusbar, unit)
  7.     if UnitIsPlayer(unit) and UnitIsConnected(unit) and unit == statusbar.unit and UnitClass(unit) then
  8.         _, class = UnitClass(unit)
  9.         c = CUSTOM_CLASS_COLORS and CUSTOM_CLASS_COLORS[class] or RAID_CLASS_COLORS[class]
  10.         statusbar:SetStatusBarColor(c.r, c.g, c.b)
  11.     end
  12. end
  13. hooksecurefunc("UnitFrameHealthBar_Update", colour)
  14. hooksecurefunc("HealthBar_OnValueChanged", function(self)
  15.     colour(self, self.unit)
  16. end)
  17. end


Code for removing bar behind the target frame name:
Lua Code:
  1. function RunBlackNameBackground()
  2. -- Изменяет бэкграунд на фреймах таргета и фокуса
  3. hooksecurefunc("TargetFrame_CheckFaction",
  4. function(self)
  5.     self.nameBackground:SetVertexColor(0.0, 0.0, 0.0, 0.01);
  6. end)
  7. end

Any idea on how I can make these into addons?

  Reply With Quote
04-17-22, 01:11 AM   #2
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,313
A quick and easy way is to copy/paste the code into addon.bool.no. You may have to open the .toc file in something like Notepad after you extract everything and make sure the Interface# is correct for your game client.
  • 90200 for Retail
  • 20504 for BCC
  • 11402 for Classic Era/SoM
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)
  Reply With Quote
04-17-22, 04:38 AM   #3
escodashoota
A Defias Bandit
Join Date: Apr 2022
Posts: 2
Originally Posted by SDPhantom View Post
A quick and easy way is to copy/paste the code into addon.bool.no. You may have to open the .toc file in something like Notepad after you extract everything and make sure the Interface# is correct for your game client.
  • 90200 for Retail
  • 20504 for BCC
  • 11402 for Classic Era/SoM
i used this website and made sure the interface # was correct, but it wasn't working after logging in.
  Reply With Quote
04-21-22, 01:38 PM   #4
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,313
You need to either remove the function enclosures or call them. I suggest removing them since the functions hooked already exist on load.
Lua Code:
  1. -- Включение цвета классов на полосах здоровья
  2. hooksecurefunc("HealthBar_OnValueChanged",function(self)
  3.     local unit=self.unit;
  4.     if UnitIsPlayer(unit) and UnitIsConnected(unit) then
  5.         local _,class=UnitClass(unit);
  6.         if class then
  7.             self:SetStatusBarColor(ColorMixin.GetRGB(CUSTOM_CLASS_COLORS and CUSTOM_CLASS_COLORS[class] or RAID_CLASS_COLORS[class]));
  8.         end
  9.     end
  10. end);
  11.  
  12. -- Изменяет бэкграунд на фреймах таргета и фокуса
  13. hooksecurefunc("TargetFrame_CheckFaction",function(self)
  14.     self.nameBackground:SetVertexColor(0.0, 0.0, 0.0, 0.01);
  15. end);

PS: I cleaned up the code some. Hooking UnitFrameHealthBar_Update() was unnecessary as it ended up triggering HealthBar_OnValueChanged() anyway. Also while RAID_CLASS_COLORS inherits ColorMixin, CUSTOM_CLASS_COLORS isn't so clearly defined as it's not a Blizzard variable. This is why :GetRGB() is called from ColorMixin instead of the color tables. Note '.' was used instead of ':' so the color table could be given to the function as a reference instead of it trying to take ColorMixin as self.
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)
  Reply With Quote
05-09-22, 01:10 AM   #5
Vremon
A Deviate Faerie Dragon
AddOn Author - Click to view addons
Join Date: Jan 2022
Posts: 14
Originally Posted by SDPhantom View Post
You need to either remove the function enclosures or call them. I suggest removing them since the functions hooked already exist on load.
Lua Code:
  1. -- Включение цвета классов на полосах здоровья
  2. hooksecurefunc("HealthBar_OnValueChanged",function(self)
  3.     local unit=self.unit;
  4.     if UnitIsPlayer(unit) and UnitIsConnected(unit) then
  5.         local _,class=UnitClass(unit);
  6.         if class then
  7.             self:SetStatusBarColor(ColorMixin.GetRGB(CUSTOM_CLASS_COLORS and CUSTOM_CLASS_COLORS[class] or RAID_CLASS_COLORS[class]));
  8.         end
  9.     end
  10. end);
  11.  
  12. -- Изменяет бэкграунд на фреймах таргета и фокуса
  13. hooksecurefunc("TargetFrame_CheckFaction",function(self)
  14.     self.nameBackground:SetVertexColor(0.0, 0.0, 0.0, 0.01);
  15. end);

PS: I cleaned up the code some. Hooking UnitFrameHealthBar_Update() was unnecessary as it ended up triggering HealthBar_OnValueChanged() anyway. Also while RAID_CLASS_COLORS inherits ColorMixin, CUSTOM_CLASS_COLORS isn't so clearly defined as it's not a Blizzard variable. This is why :GetRGB() is called from ColorMixin instead of the color tables. Note '.' was used instead of ':' so the color table could be given to the function as a reference instead of it trying to take ColorMixin as self.
hello i try iy aswell the script with healthbar change but its look like the bar at some point its change bacj to green or sometime its appear green not class color and after changes the color ,for target and focus frames does that any othet way to fix this?
  Reply With Quote
05-09-22, 01:03 PM   #6
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,313
Strange, it works fine for me.
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Class Colored Names on Frames & No Background behind Name on Frames

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