Trying to move the menu to the middle of the screen in VX ace

And while I can do that with

Code:
@command_window.x = 190 
@command_window.y = 150

that only works for the default size of 544 and 416. If I were to change the screen size I'd have to constantly fiddle with it to put it back in the middle, and knowing how indecisive I am I would be doing that a lot. I did some digging through the engine and found

Code:
  def update_placement
    self.x = (Graphics.width - width) / 2
    self.y = (Graphics.height * 1.6 - height) / 2
  end

this in window_titlecommand. I tried adding it to the scenebase create_command_window instead as

Code:
@command_window.x = (Graphics.width - width) / 2

to see if it would work, but I get an error that width isn't defined. I've tried combing through the maker to see where I'm missing it could have been defined to see if adding it would help, but I haven't had any luck so far. I tried googling only that didn't really turn up anything either. What am I missing here? 😩
Please show us a screenshot of the window you're trying to change (I assumed it WAS the title screen menu, as that's the only one that's smaller than the game window and could be centered). Is that the ENTIRE error message? If not, please copy/paste the whole error message (or give a screenshot), showing the script name and line number, along with a screenshot of your script so we can see what line it's throwing the error on.
Screenshot_77.png

The menu window it the one I'm trying to move, and I was trying to copy how the title commands window gets centered since it has code telling it to move to the middle, it isn't there by default.
Screenshot_78.png

And this is what happens when I paste my attempt in.
It would have helped if you said you were using MJSHI's non combat menu.
In the script under Window_GameEnd
add in the update placement method and change the width and height parts
Ruby:
class Window_GameEnd
 
  def update_placement
    self.x = (Graphics.width - self.width) / 2
    self.y = (Graphics.height - self.height) / 2
  end
end
Except I'm not using their script? I'm fiddling around in ruby trying to learn it again.

And what exactly amd I changing the width and height to? The size of the game window? Since adding it before with the other attempt didn't change it either, and adding it to this one just gives me a syntax error.

Screenshot_80.png
Screenshot_81.png
you can't use a number for a self reference.
Looks like you need some ruby tutorials (as a refresher). There are a couple on the forums here. look at the them and you'll understand more.

So when you create the command window it has a width and height make for it.
They are created under the Window_MenuCommand class.
they are window_width and window_height
put the two line I gave above where you have your x and y position statements
Ruby:
    self.x = (Graphics.width - self.width) / 2
    self.y = (Graphics.height - self.height) / 2
or this could work as well
Ruby:
    self.x = (Graphics.width - window_width) / 2
    self.y = (Graphics.height - window_height) / 2
The only ruby tutorials I've every come close to understanding is the "slip into ruby" ones, and even then it's only of so much help for me. I'm sadly a "bang my head against the wall till something gives" or "be heavily guided" type when it comes to how I learn because I just haven't been able to put the metaphorical 2+2 together very well on my own, but I still want to try to do so.

Screenshot_85.png


Under window command it only mentions width, not height. I did not change that part of the script, only the commands that appeared.

Screenshot_84.png

Found them in window_command and tried adding the width and height thing to see if that would help at all.
Screenshot_83.png

Using either of the options you gave me results in that same error.
Using either of the options you gave me results in that same error.
Sorry, I'll try to explain more.

Read the error message and you see that it says Scene_Menu.
Not Window_MenuCommand
So when referencing the menu command window you need to use @command_window
Ruby:
    @command_window.x = (Graphics.width - window_width) / 2
    @command_window.y = (Graphics.height - window_height) / 2

@command_window is created in Scene_Menu. You reference it with the instance variable that was created for it.
If you put these commands into the class Window_MenuCommand,
then you could have used self for the reference as it would then refer to the window class itself that the code is in.

So you could also use the initialize under the class Window_MenuCommand
def initialize
super((Graphics.width - window_width / 2), (Graphics.height - window_height / 2)) # should work
select_last
end
the numbers there originally are referring to x & y -> super(x, y) but show super(0, 0)
since it needs actual values to define the integer number for the x and y.

Screenshot_87.png

and then when I tried to give it what I thought it wanted
Screenshot_88.png


And I have tried all those tutorials at some point within the last five years. They did not work for me because it's not as simple as I need it. Think less 101 and more baby's first building blocks, I am that dense. Also I HAD done it as an @command_window in prior attempts, but I just got the same results, I just hadn't bothered putting it back for the screen shot, so the "self" ones were the second attempt to see if that would work.
baby's first building blocks
You should not be programming then if all this is that challenging for you.
It makes me confused that you said you learned ruby before, All of this should be easy to pick up for you with past experience.

You need to show those lines, from what I can see you do not have a comma in there.

But at this point I don't know where your making changes since I gave you several options.
However, since you are not intuitive enough to make the code work for you, then I suggest that you post your fiddling script here and someone will correct it for you.
Correction. I never said I learned ruby. I said I was trying to learn it again, and I keep trying over and over because I keep failing because I still have a hard time making it click in my head. It has been about three years since I last even touched ruby, there is alot I have forgotten from what I had managed to learn. I got a bit farther than I am now, but I still couldn't do that much. It's hard to learn because I haven't found a way for it to make sense to me fully yet. That's not my fault, nor the fault on people who have made tutorials. They wrote them as it made sense to them, I just don't find them making as much sense to me. That doesn't mean I should give up and I will learn nothing if someone "fixes it for me".

I did at the comma, but then it said it didn't want that. I have tried to paste exactly what you told me to and tried to show the areas I thought were relevant of the script I'm working with.
Screenshot_90.png


Screenshot_89.png

Screenshot_91.png
OK SO

After talking with one of my friends that happened to still be online this late at night, I got the solution I was looking for.

set x = ((graphics.width / 2)- (one half of the menu window size))
so ((Graphics.width / 2) - 80)

The window is usually set at 160, hence the 80.


Code:
@command_window.x = ((Graphics.width / 2) - 80)
@command_window.y = ((Graphics.height / 2) - 60)


This was the magic I needed.

Default 544x416 or the largest size 640x480
Screenshot_95.png


It stays PERFECTLY in the middle.

Screenshot_94.png


He even helped me see where I was screwing up with it while doing this. I was trying to pull dynamic variables, but wasn't setting it up correctly. The easier solution was to just use the above bit of script, since it would divide by the game window then subtract by half the width of the menu window. That way it's always going to look centered, no matter the size. Exactly what I wanted.
I said I was trying to learn it again, and I keep trying over and over because I keep failing because I still have a hard time making it click in my head
@QuizicalGin what happened to you there was that you messed with a scene script but tried to define the x and y coordinates of a window as if the window were the scene itself. It was quite messy.

Code:
@command_window.x = (Graphics.width - @command_window.width) / 2
@command_window.y = (Graphics.height - @command_window.height) / 2

This way you don't need to manually calculate how wide or tall your command window actually is.
Oh snap, that's even better! Thanks Kyonides!

And thanks for that link Roninator. I've been avoiding pay courses, but I may have to finally break down.

Original thread: https://forums.rpgmakerweb.com/threads/trying-to-move-the-menu-to-the-middle-of-the-screen-in-vx-ace.134434/