The title sums up this topic pretty nicely. I'd like some general information on chaning the main menu (the one in-game, not the title screen). Specifically, right now I'd like know if it's possible to change the amount of space between an actor's name and nickname. I want to reduce it, as for this particular project I'm using the "Nickname" field for surnames. It'd just look odd, having a huge gulf between the two names.
Editing the Main Menu
Learning Ruby and RGSSxI'm not sure about the kind of menu you're talking about. The nickname can only be found in the status menu, but there's still the class name in between. Did you mix up nickname and class? Whatever, here's a little help …
Take a look at Windows_Status. You can search with Ctrl+F for nick. Line 44 is the first and only result, so that must be it! draw_actor_nickname is a pretty descriptive name. That method is defined in Window_Base. Search for it there. If you have found it, you can between the parentheses the argument it expects: (actor, x, y, width = 180).
You don't want to change actor or width. As you may know the origin (of windows or your screen in general) is upper left:
( 0, 0)------(544, 0)
| |
| |
| |
( 0,416)------(544,416)
So if you want to move the nickname further left, you have to decrease x.
Now back to Window_Status, maybe make a copy of it or add a comment (green and starts with #) to find your edit faster in the future if you want to revert it. Hopefully you remember that x is the second argument (arguments are seperated by commas) and here it's currently 288. Well, change it. I guess that's probably all you need to know, isn't it?
If you weren't talking about the status menu, maybe this'll help you changing the right one. Experimenting is better than watching videos.
Take a look at Windows_Status. You can search with Ctrl+F for nick. Line 44 is the first and only result, so that must be it! draw_actor_nickname is a pretty descriptive name. That method is defined in Window_Base. Search for it there. If you have found it, you can between the parentheses the argument it expects: (actor, x, y, width = 180).
You don't want to change actor or width. As you may know the origin (of windows or your screen in general) is upper left:
( 0, 0)------(544, 0)
| |
| |
| |
( 0,416)------(544,416)
So if you want to move the nickname further left, you have to decrease x.
Now back to Window_Status, maybe make a copy of it or add a comment (green and starts with #) to find your edit faster in the future if you want to revert it. Hopefully you remember that x is the second argument (arguments are seperated by commas) and here it's currently 288. Well, change it. I guess that's probably all you need to know, isn't it?
If you weren't talking about the status menu, maybe this'll help you changing the right one. Experimenting is better than watching videos.
Everything he said up to here. Don't change anything in the Window_Status script directly. Ruby allows for overwriting of methods and classes. Take advantage of that.
What you do is start with a blank script page by clicking on the space below Materials in the pane to the left (where it says "insert here"). If there's not an empty line, right click and choose insert. For the name field on the bottom, type Window_Status. We want to make a change to the class Window_Status, so copy/paste (or just copy) the first line of that class. We're only changing one method, so that's the only one you'll need to put underneath. So your 'script' should look like this:
class Window_Status < Window_Selectable #-------------------------------------------------------------------------- # * Draw Block 1 #-------------------------------------------------------------------------- def draw_block1(y) draw_actor_name(@actor, 4, y) draw_actor_class(@actor, 128, y) draw_actor_nickname(@actor, 288, y) endendCapitalization counts! I left the comments in as a Best Practice - it also shows I just copy/pasta'd to avoid any potential typos. You need to copy the entire method - not just the one line [a method runs from a def to an end, and you need a second end for the class], but this gives you some opportunities.
As of now, nothing in the game has changed, since your 'new' method is exactly the same as the old method. But now you're free to change those values, and you know that if you screw up (and you will while you're learning, and even after) you've got the original code left untouched up top. For things like graphics placement - you can either go through some calculations, or you can just guess and pick a number, playtest the game (F12) and see how it looks, close the game, adjust as needed, lather, rinse, repeat.
As it is written now, the order is name, class, nickname. You can tell by the y value that they will all appear on the same line. If you swap the x values (the 128 and 288) for class and nickname, the line will now read name, nickname, class - which is the way you want it to be.
The good part about doing it this way is no matter what you now do to this block of code, you can always delete it and the game will go back to the original version sitting nice and safe up top.
If you find the space for the name or the nickname is much longer than you need, you can do this process again, starting with picking a blank space below materials for a new 'script', but for the class Window_Base and copy the class Window_Base line and the draw_actor_nickname method (or draw_actor_name - or even both).
class Window_Base < Window #-------------------------------------------------------------------------- # * Draw Name #-------------------------------------------------------------------------- def draw_actor_name(actor, x, y, width = 112) change_color(hp_color(actor)) draw_text(x, y, width, line_height, actor.name) end #-------------------------------------------------------------------------- # * Draw Class #-------------------------------------------------------------------------- def draw_actor_class(actor, x, y, width = 112) change_color(normal_color) draw_text(x, y, width, line_height, actor.class.name) end #-------------------------------------------------------------------------- # * Draw Nickname #-------------------------------------------------------------------------- def draw_actor_nickname(actor, x, y, width = 180) change_color(normal_color) draw_text(x, y, width, line_height, actor.nickname) endend [i copied all three since they were right next to each other in the originating class]
There you can change the 180 for nickname or 112 for name to something else Maybe the space for name is too short for you, or nickname is too long, especially if you've changed the order on the line as I suggested above.. You have to work with this in conjunction with the window placement from the first method, or you can have the end of the nickname writing over the top of the class, or something similar.
Keep playing with the numbers until it looks right to you.
Congratulations - you've just written two custom scripts 🙂
another little tip to add on to Mouser's nice post 😉
You can do a few things to work with changing text string lengths. If you look at the help file, in the Bitmap Class, it'll show you the draw_text def, but also a test_str def. This one is pretty great for adjusting strings to their size.
So if you do
text_str(actor.name).widthIt'll tell you how long your actor's name is in pixels. I've noticed if you add a 2-5 pixels to it, then you're usually golden 😉 (For some reason text always gets cropped a little in the game.
The next way is really very simple. Use #{variable} where variable is some kind of stored information that you want to put in a text string. So we want to add the actor's name to their surname. Then we'll make a brand new def like so:
You can do a few things to work with changing text string lengths. If you look at the help file, in the Bitmap Class, it'll show you the draw_text def, but also a test_str def. This one is pretty great for adjusting strings to their size.
So if you do
text_str(actor.name).widthIt'll tell you how long your actor's name is in pixels. I've noticed if you add a 2-5 pixels to it, then you're usually golden 😉 (For some reason text always gets cropped a little in the game.
The next way is really very simple. Use #{variable} where variable is some kind of stored information that you want to put in a text string. So we want to add the actor's name to their surname. Then we'll make a brand new def like so:
Code:
def draw_actor_fullname(actor, x, y, width = 250) change_color(hp_color(actor)) draw_text(x, y, width, line_height, "#{actor.name} #{actor.nickname}")end
Thanks, everyone. Your responses show me one thing very clearly- I need to learn basic scripting. 🙂 I'll do that and take all of your advice into account.
Original thread: https://forums.rpgmakerweb.com/threads/editing-the-main-menu.24824/