Quantcast
WoWInterface - View Single Post - Anchoring cast bar to personal resource display
View Single Post
09-16-17, 04:59 AM   #3
nKweo
A Deviate Faerie Dragon
 
nKweo's Avatar
Join Date: Oct 2012
Posts: 16
Thanks! Unfortunately the first if-statement doesn't seem to work the way one might assume though. The cast bar still anchors to a random nameplate when the PRD is hidden:
Code:
local function attach()
if CastingBarFrame:GetParent() ~= NamePlatePlayerResourceFrame and NamePlatePlayerResourceFrame then
	CastingBarFrame:ClearAllPoints()
	CastingBarFrame:SetPoint("TOP",NamePlatePlayerResourceFrame,"BOTTOM",0,-28)
	--CastingBarFrame.SetPoint = function() end (seems to break the code)
else
	CastingBarFrame:ClearAllPoints()
	CastingBarFrame:SetPoint("TOP",UIParent,"BOTTOM",0,160)
	--CastingBarFrame.SetPoint = function() end (seems to break the code)
end
end

local f = CreateFrame("frame")
f:RegisterUnitEvent("UNIT_SPELLCAST_START","player")
f:RegisterUnitEvent("UNIT_SPELLCAST_CHANNEL_START","player")
f:SetScript("OnEvent",attach)
Substituting the if-statement with a simple UnitExists("target") statement seems to work ok though (although it is not as elegant):
Code:
if (UnitExists("target")) then
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?
  Reply With Quote