Skip to content

Instantly share code, notes, and snippets.

@obble

obble/cp.lua Secret

Last active October 15, 2015 13:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save obble/a6f1a53f258ea4253756 to your computer and use it in GitHub Desktop.
Save obble/a6f1a53f258ea4253756 to your computer and use it in GitHub Desktop.
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