Files
ShagaTweaks/mods/nameplate-classcolor.lua
T
shagu 6c26bc6190 core: don't rely on sane global environment
some addons like to provide a broken _G variable to
the global environment breaking every other addon that
relies on it if existing. With this commit, make ShaguTweaks
no longer re-use the global _G, even if existing.
2022-11-19 16:59:12 +01:00

23 lines
733 B
Lua

local _G = ShaguTweaks.GetGlobalEnv()
local GetUnitData = ShaguTweaks.GetUnitData
local module = ShaguTweaks:register({
title = "Nameplate Class Colors",
description = "Changes the nameplate health bar color to the class color.",
expansions = { ["vanilla"] = true, ["tbc"] = true },
enabled = nil,
})
module.enable = function(self)
if ShaguPlates then return end
table.insert(ShaguTweaks.libnameplate.OnUpdate, function()
local name = this.name:GetText()
local class, _, elite, player = GetUnitData(name, true)
if class and player then
local color = RAID_CLASS_COLORS[class] or { r = .5, g = .5, b = .5, a = 1 }
this.healthbar:SetStatusBarColor(color.r, color.g, color.b, 1)
end
end)
end