I'm working on an Addon to monitor CC on a target. Basically what I'm trying to create is a second "Focus".
I want to make a unit frame where you can set and clear a unitID to keep track of an enemy's health and debuffs. I'm running into trouble trying to create the unitframe. I've found plenty of code samples online for creating a unit frame for yourself/party/raid or target. How do you create a unitframe for a stored unit ID value?
Any code samples here are much appreciated!
Here's what I have so far... I just have the frames drawn, and I'm not sure how to update them with actual health values.
Code:
local CCHB_unitHealth = CreateFrame("Frame", "CCHB_unitHealth", CCHB_mainframe)
CCHB_unitHealth:SetBackdrop(defaultBackdrop)
CCHB_unitHealth:SetBackdropColor(0,0,0,0)
CCHB_unitHealth:SetMovable(false)
CCHB_unitHealth:SetSize(200,25)
CCHB_unitHealth:SetPoint("LEFT", CCHB_mainframe, "LEFT", 25, -10)
local CCHB_unitHealthSB = CreateFrame("StatusBar", "CCHB_unitHealthSB", UIParent, "SecureUnitButtonTemplate")
CCHB_unitHealthSB:SetPoint("CENTER", CCHB_unitHealth, "CENTER", 0, 0)
CCHB_unitHealthSB:SetWidth(195)
CCHB_unitHealthSB:SetHeight(20)
CCHB_unitHealthSB:SetStatusBarTexture("Interface\\TARGETINGFRAME\\UI-StatusBar")
CCHB_unitHealthSB:GetStatusBarTexture():SetHorizTile(false)
CCHB_unitHealthSB:GetStatusBarTexture():SetVertTile(false)
CCHB_unitHealthSB:SetStatusBarColor(0, 0.65, 0)
CCHB_unitHealthSB:SetMinMaxValues(0, 100)
local CCHB_unitName = CCHB_unitHealth:CreateFontString("CCHB_unitName", "OVERLAY")
CCHB_unitName:SetPoint("CENTER", CCHB_unitHealth, "CENTER")
CCHB_unitName:SetFont("Fonts\\FRIZQT__.TTF", 12, "OUTLINE")
CCHB_unitName:SetJustifyH("CENTER")
CCHB_unitName:SetShadowOffset(1, -1)
CCHB_unitName:SetTextColor(1, 1, 1)
CCHB_unitName:SetText("No Target")