View Single Post
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