MainMenuBar Scripts

So ive created a .lua and .toc file that ive created to just run the simple scripts i use to set my UI.

However… the ones that simply will not work are scripts related to mainmenubar or any scripts moving a frame. For example if i run

/script MainMenuBar:SetScale(1.1)

it works.

but if i put

MainMenuBar:SetScale(1.1) in a LUA file it doesnt work.

The same is true for

MainMenuBar:ClearAllPoints()
MainMenuBar:SetPoint(“CENTER”, 0,-350)
MainMenuBar.Setpoint = Function() end

the manual /script version works, but if placed in a LUA file it doesnt.

how can i fix this? Nothing affects Main menu bar, and none of my movement scripts work unless done manually when i log in.

Problem is your addon version is executing the code before the bar exists. You need to hook it into an event that fires after the MainMenuBar has been created. Unfortunately, I don’t know what that event is but there’s plenty of talented people around here who can point you in the right direction.

This would delay the code, if that helps:

local f = CreateFrame()
f:SetScript("OnEvent", function()
  -- doStuffHere()
)
f:RegisterEvent("PLAYER_LOGIN")

However… by the time your addon kicks in the MainMenuBar object should already exist. It might be getting changed by other stuff in the loading process, maybe?

The bars exist before 3rd party addons are loaded. There is a layout manager that adjust things when bars are added/removed. I haven’t looked at it in ages but I think there an attribute or key you can set to ignore the manager.

That and 0 is not a valid frame to SetPoint to.
That and function requires a lower case f
That and Setpoint should have both x and y offsets

You might get away with just using brute force.

MainMenuBar:SetScale(1.1)
MainMenuBar:ClearAllPoints()
MainMenuBar:SetPoint("CENTER", UIParent, 0 ,-350)
MainMenuBar.SetScale = function() end
MainMenuBar.ClearAllPoints = function() end
MainMenuBar.SetPoint = function() end

thanks for the help, ill look into it a bit more, im not a coder in anyway, im kinda learning a bit about it and thought messing with a basic UI addon for myself would be a great way to mess around. Ill try some stuff,

I tried checking my grammar, changed the spelling of function to a lowercase f. still didnt load or even do the scaling.

Ignore my comments about SetPoint, your original code was using the default frame parent so it’s fine :roll_eyes:.

thats alright, still doesnt work regardless. none of my stuff for the mainmenubar work at all, and on other frames i cannot get them to do anything other than scale right now so clearly i have a lot missing.

OKAY i found out why it wont move… i um… had a lowercase S in the “SetPoint = fuction() end”

and it moved! except, it only moved the one bar and not all the other ones in the entire main menu group like it did if i just /script it.

like action bar one is there… in the correct position, but all the other ones are actually just gone. missing. not on screen at all. Do i need to move those all individually?

install:

https://www.curseforge.com/wow/addons/bug-grabber
and
https://www.curseforge.com/wow/addons/bugsack

to help with identiying errors.