Moving Frames upon Login (LUA)

Hey, folks. I have this following macro that I click when I log in to the game to relocate my frame/target frame to specific places so that it’s uniform across all characters.

It slightly annoys me that I have to click this thing manually, so I wanted to move this to a tiny addon instead, but I can’t get it to work.

This is the macro I’m using, per some documentation that I found:

/run PlayerFrame:ClearAllPoints()PlayerFrame:SetPoint("RIGHT",UIParent,"CENTER",-375,300)PlayerFrame.SetPoint=function()end
/run TargetFrame:ClearAllPoints()TargetFrame:SetPoint("RIGHT",UIParent,"CENTER",-150,300)TargetFrame.SetPoint=function()end

The last attempt I made at converting this into an addon is as follows:

local function MFPosition(self, event)
    PlayerFrame.ClearAllPoints()
    PlayerFrame.SetPoint("RIGHT", UIParent, "CENTER", -375, 300)
    PlayerFrame.SetUserPlaced(true);
    TargetFrame.ClearAllPoints()
    TargetFrame.SetPoint("RIGHT", UIParent, "CENTER", -150, 300)
    TargetFrame.SetUserPlaced(true);
end

local events = CreateFrame('Frame');
events:RegisterEvent('PLAYER_LOGIN');
event:SetScript('OnEvent', MFPosition)

Not sure what I’m doing wrong, though I have found that the API really isn’t documented very well at all, and what docs DO exist are community-made and scattered all over the place.

Can anyone help me out? I’d really appreciate it.

Have you tried right clicking these frames, and select Move Frame\Unclock Frame\[move the frame] then lock the frame again?

Otherwise, in your addon change:

PlayerFrame. to PlayerFrame:
and:
TargetFrame. to TargetFrame:

Yeah, I’ve tried to just lock frames in place, but the reason I wanted to use an addon/macro is so they’d be exactly in the same spot all the time.

I guess it’s sort of picky, but I just wanted the automation so if I ever rolled new characters, it was one less thing to worry about.

Still isn’t working with PlayerFrame: and TargetFrame:. :confused:

You were missing a s after event in the SetScript line.

Get rid of everything and just make your addon:

PlayerFrame:ClearAllPoints()
PlayerFrame:SetPoint("RIGHT", UIParent, "CENTER", -375, 300)
PlayerFrame:SetUserPlaced(true);
TargetFrame:ClearAllPoints()
TargetFrame:SetPoint("RIGHT", UIParent, "CENTER", -150, 300)
TargetFrame:SetUserPlaced(true);

Oh sweet! Thanks so much! Working perfectly now.