-
-
Save obble/a6f1a53f258ea4253756 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local create = function(plate) | |
plate.cp = plate:CreateFontString(nil, 'OVERLAY') | |
plate.cp:SetFont(STANDARD_TEXT_FONT, 20, 'OUTLINE') | |
plate.cp:SetPoint('BOTTOMLEFT', plate, 'TOPLEFT') | |
plate.cp:SetTextColor(0, .8, .4) | |
plate.cp:Hide() | |
plate.modded = true | |
end | |
local isPlate = function(frame) | |
local overlayRegion = frame:GetRegions() | |
if not overlayRegion or overlayRegion:GetObjectType() ~= 'Texture' | |
or overlayRegion:GetTexture() ~= [[Interface\Tooltips\Nameplate-Border]] then | |
return false | |
end | |
return true | |
end | |
local matchPlate = function(plate) | |
if plate.cp then | |
local health = plate:GetChildren() | |
local _, _, name = plate:GetRegions() | |
local text = name:GetText() | |
local target = GetUnitName'target' | |
local cp = GetComboPoints() | |
if target == text and health:GetAlpha() == 1 and cp > 0 then | |
plate.cp:Show() | |
plate.cp:SetText(cp) | |
else plate.cp:Hide() end | |
end | |
end | |
local f = CreateFrame'Frame' | |
f:SetScript('OnUpdate', function() | |
local frames = {WorldFrame:GetChildren()} | |
for _, plate in ipairs(frames) do | |
if isPlate(plate) and plate:IsVisible() then | |
if not plate.modded then create(plate) end | |
matchPlate(plate) | |
end | |
end | |
end) | |
-- |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment