Return unit frame for a given unit
localLGF=LibStub("LibGetFrame-1.0")
localframe=LGF.GetUnitFrame(unit , options)
localcallback=function(event, frame, unit)
ifevent=="GETFRAME_REFRESH" then-- cache was refreshedendifevent=="FRAME_UNIT_UPDATE" then-- 'frame' was updated and is now a match for 'unit'endifevent=="FRAME_UNIT_REMOVED" then-- 'frame' was updated and is no longer a match for 'unit'endendLGF.RegisterCallback("MyAddonName", "GETFRAME_REFRESH", callback)
LGF.RegisterCallback("MyAddonName", "FRAME_UNIT_UPDATE", callback)
LGF.RegisterCallback("MyAddonName", "FRAME_UNIT_REMOVED", callback)
LGF:GetUnitFrame(unit, options)Options:
framePriorities : array
ignorePlayerFrame : boolean (default true)
ignoreTargetFrame : boolean (default true)
ignoreTargettargetFrame : boolean (default true)
ignorePartyFrame : boolean (default false)
ignorePartyTargetFrame : boolean (default true)
ignoreRaidFrame : boolean (default false)
playerFrames : array
targetFrames : array
targettargetFrames : array
partyFrames : array
partyTargetFrames : array
raidFrames : array
ignoreFrames : array
returnAll : boolean (default false)
If returnAll is false, GetUnitFrame will return a single best match
For arrays check LibGetFrame-1.0.lua code for defaults
LGF:ScanForUnitFrames()Ask lib to do a new scan of frames.
This scan can take a few frames to be completed.
You should not expect the cache use by LGF:GetUnitFrame to be updated in the same frame as this ScanForUnitFrames call.
Use lib's callbacks to know when the cache is refresh.
LGF:GetUnitNameplate(unit)Return health bar for a nameplate unit, works with a variety of addons
-- Fired after a scan complete and cache refreshedLGF.RegisterCallback("MyAddonName", "GETFRAME_REFRESH", function(event) end)-- Fired when a frame is a new match for a unit (it does not test if it is the BEST match!)LGF.RegisterCallback("MyAddonName", "FRAME_UNIT_UPDATE", function(event, frame, unit) end)-- Fired when a frame is not a new match for a unit anymoreLGF.RegisterCallback("MyAddonName", "FRAME_UNIT_REMOVED", function(event, frame, unit) end)localLGF=LibStub("LibGetFrame-1.0")
localLCG=LibStub("LibCustomGlow-1.0")
localframe=LGF.GetUnitFrame("player")
ifframethenLCG.ButtonGlow_Start(frame)
-- LCG.ButtonGlow_Stop(frame)endlocalLGF=LibStub("LibGetFrame-1.0")
localLCG=LibStub("LibCustomGlow-1.0")
localframes=LGF.GetUnitFrame("target", {
ignorePlayerFrame=false,
ignoreTargetFrame=false,
ignoreTargettargetFrame=false,
returnAll=true,
})
for_, frameinpairs(frames) doLCG.ButtonGlow_Start(frame)
--LCG.ButtonGlow_Stop(frame)endlocalframe=LGF.GetUnitFrame("player", {
ignoreFrames= { "Vd2.*", "Vd3.*" }
})localLGF=LibStub("LibGetFrame-1.0")
localLCG=LibStub("LibCustomGlow-1.0")
-- list of units i want glowinglocalglow_units= {
player=true
}
-- track which frame is glowing per unitlocalglow_unit_frames= {}
-- glow them using current cacheforunitinpairs(glow_units) dolocalframe=LGF.GetUnitFrame("player")
ifframethenLCG.ButtonGlow_Start(frame)
glow_unit_frames[unit] =frameendendlocalcallback=function(event, frame, unit)
ifnotglow_units[unit] thenreturnend-- new match for GetUnitFrame(unit), check if it's different from previous "best match" returnedlocalnew_best_match=LGF.GetUnitFrame(unit)
ifnew_best_match==nilthen-- didn't found a best match for this unitifglow_unit_frames[unit] then-- stop previous glowLCG.ButtonGlow_Stop(glow_unit_frames[unit])
glow_unit_frames[unit] =nilendelseifnew_best_match~=glow_unit_frames[unit] then-- best match found, but different from previous oneifglow_unit_frames[unit] then-- stop previous glowLCG.ButtonGlow_Stop(glow_unit_frames[unit])
endLCG.ButtonGlow_Start(new_best_match)
glow_unit_frames[unit] =new_best_matchendendLGF.RegisterCallback("MyAddonName", "FRAME_UNIT_UPDATE", callback)
LGF.RegisterCallback("MyAddonName", "FRAME_UNIT_REMOVED", callback)