Anchor PlayerFrame and TargetFrame to CastingBarFrame

I’ve been trying to figure out how to anchor my PlayerFrame and TargetFrame to CastingBarFrame when the “Cast Bar Underneath” option on PlayerFrame is not enabled. When the option is enabled, I’d like to anchor them to UIParent. I can successfully anchor them to CastingBarFrame in MoveAnything, but it breaks when I disable “Cast Bar Underneath”. If I try it with my own scripts, it breaks no matter what the setting is. I’m trying to get rid of MoveAnything, but I still need it to do this, even if it doesn’t work in all situations.

Here are my anchors on CastingBarFrame:

PlayerFrame:SetMovable(true)
PlayerFrame:ClearAllPoints()
PlayerFrame:SetPoint("BOTTOMRIGHT",CASTINGBARFRAME,"LEFT", -20, 0)
PlayerFrame:SetUserPlaced(true)
PlayerFrame:SetMovable(false)

TargetFrame:SetMovable(true)
TargetFrame:ClearAllPoints()
TargetFrame:SetPoint("BOTTOMLEFT",CASTINGBARFRAME,"RIGHT", 20, 0)
TargetFrame:SetUserPlaced(true)
TargetFrame:SetMovable(false)

FocusFrame:SetMovable(true)
FocusFrame:ClearAllPoints()
FocusFrame:SetPoint("BOTTOMLEFT",TARGETFRAME,"TOPRIGHT", 0, 100)
FocusFrame:SetUserPlaced(true)
FocusFrame:SetMovable(false)

Here are my anchors on UIParent:

PlayerFrame:SetMovable(true)
PlayerFrame:ClearAllPoints()
PlayerFrame:SetPoint("BOTTOMRIGHT",UIPARENT,"BOTTOM", -110, 200)
PlayerFrame:SetUserPlaced(true)
PlayerFrame:SetMovable(false)

TargetFrame:SetMovable(true)
TargetFrame:ClearAllPoints()
TargetFrame:SetPoint("BOTTOMLEFT",UIPARENT,"BOTTOM", 110, 200)
TargetFrame:SetUserPlaced(true)
TargetFrame:SetMovable(false)

FocusFrame:SetMovable(true)
FocusFrame:ClearAllPoints()
FocusFrame:SetPoint("BOTTOMLEFT",UIPARENT,"TOPRIGHT", 0, 100)
FocusFrame:SetUserPlaced(true)
FocusFrame:SetMovable(false)

Frame names (and pretty much everything else) are case sensitive

CastingBarFrame
TargetFrame
etc.

If you are not sure you can use
/run print(CastingBarFrame)
or whetever you think the frame name is and if it prins nil to the chatframe, it’s not a valid frame.

That did work. Now I just need to make it so it anchors to UIParent when “Cast Bar Underneath” is selected.

UIParent is also case sensitive (looking at the code in your OP)

I don’t know what or where that option is.

If you right click PlayerFrame, it’s under Move Frame. It changes the CastingBarFrame anchor from UIParent to PlayerFrame.

If you have the PlayerFrame anchored to the CastingBarFrame and then try and anchor the CastingBarFrame to the PlayerFrame (without re-anchoring the PlayerFrame to something else first) you will get a dependancy error.

If you re-anchor the PlayerFrame to UIParent first and then change the CastingBar position you should be ok.

You can’t anchor something to another thing that is anchored to itself

Edit: I’m not sure why you don’t unlock the unit frames, drag them where you want them and re-lock. You can then toggle “Cast Bar Underneath” to your0 hearts content without any code.
But maybe I’m missing something.

1 Like

The reason I’m doing this is that anchoring to UIParent makes the frames static. If I anchor to CastingBarFrame, they will move up and down with the cast bar, depending on which UI elements appear underneath it. This makes it so that the frames are never overlapping with the pet bar or stance bar depending on the situation, but they are also as low on my interface as possible. That’s why I need the script to change anchors when “Cast Bar Underneath” is checked. I hope that makes sense.

EDIT: For anyone referencing this thread in the future, I ended up anchoring them to GroupLootContainer.

1 Like