WoWInterface - View Single Post - Anchoring cast bar to personal resource display
View Single Post
09-16-17, 10:19 AM   #4
A Frostmaul Preserver
AddOn Author - Click to view addons
Join Date: Jun 2016
Posts: 256
Originally Posted by nKweo View Post
Substituting the if-statement with a simple UnitExists("target") statement seems to work ok though (although it is not as elegant):
if (UnitExists("target")) then
I wouldn't do it that way because it's possible to have a target while the personal resource display isn't showing which would cause the code to specifically attach it to a wrong nameplate (or perhaps cause the code to panic and return a lua error if no nameplates are in range.)

local function attach()
	if C_NamePlate.GetNamePlateForUnit("player") then
		--CastingBarFrame.SetPoint = function() end (seems to break the code)
		--CastingBarFrame.SetPoint = function() end (seems to break the code)

local f = CreateFrame("frame")
Turns out NamePlatePlayerResourceFrame can't be reliably used, using C_NamePlate.GetNamePlateForUnit("player") instead gets the desired results (at least from my limited testing it does.)
Works with both default cast bar, and with "Cast Bar Underneath" enabled.

Originally Posted by nKweo View Post
Moreover, there is a new problem I can't seem to solve now. I used CastingBarFrame.SetPoint = function() end to prevent to repositioned cast bar from stretching back to its original position. But entering this statement into the logic seems to break it... Can this be solved without too much hassle?
What actions are you doing in-game when this stretching happens? Is it during combat? I can't reproduce it.

Either way it breaks because CastingBarFrame:SetPoint() is calling CastingBarFrame.SetPoint, so if you zero out the latter it prevents the former from working.

Last edited by Ammako : 09-16-17 at 10:38 AM.
  Reply With Quote