How do I move protected frames?

What I’m trying to do:

  1. Build my own addon from scratch
  2. Move an element that is normally controlled by Edit Mode (such as MainMenuBar)
  3. Utilize the Frame:SetPoint() API to move the frame.

Example:

MainMenuBar:ClearAllPoints()
MainMenuBar:SetPoint('BOTTOM', UIParent, 'BOTTOM')

But it’s not doing anything.

What am I missing?

The UI is largely an event based system so timing is (largely) everything.

local f = CreateFrame("Frame")
f:RegisterEvent("PLAYER_LOGIN")
f:SetScript("OnEvent", function(self, event, ...)
	MainMenuBar:ClearAllPoints()
	MainMenuBar:SetPoint("BOTTOM")
end)

Thank you, this is working.

Until I enter combat.

I’m trying to figure out how to move the frames in such a way that it doesn’t trigger errors once entering combat.

You can’t move protected frames in combat.

Can I move protected frames prior to entering combat, then just not touch them during combat?

You can do what the system will let you but the protections are to stop people from automating combat etc. It’s up to you whether you believe what you are doing is within the rules.