Last active
October 15, 2015 13:25
-
-
Save obble/9120f63b4143b825d8c2 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.target = plate:CreateTexture(nil, 'OVERLAY') | |
plate.target:SetWidth(30) plate.target:SetHeight(30) | |
plate.target:SetPoint('BOTTOMLEFT', plate, 'TOPLEFT') | |
plate.target:SetTexture[[Interface\Tooltips\UI-Tooltip-Background]] | |
plate.target:SetVertexColor(1, 0, 0) | |
plate.target: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.target then | |
local health = plate:GetChildren() | |
local _, _, name = plate:GetRegions() | |
local text = name:GetText() | |
local target = GetUnitName'target' | |
if target == text and health:GetAlpha() == 1 then plate.target:Show() else plate.target: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