An Options Menu – Part II

On Monday we talked about Yanfly’s System Options Menu – how to install it, and how to use its basic customization features. Today, we’re going to tackle some potential issues in customizing it. First, we’re going to remove commands that we don’t want to use. Second, we’re going to look at how to use “blank” to do a little formatting. Finally, we’re going to not make it take up the “Game End” slot on our menu, but instead be its own menu.

Hiding Options from the Options Menu

This part is super easy. Let’s say, for example, that we’ve spent a ton of time on our window skin, and on our battle animations. We don’t want players to touch these, even though Yanfly gives them the option to by default. We can disable these with the addition of a single extra character – the # sign.

Find the section in the script labeled “COMMANDS” – it’s around line 106 and looks like this:

The COMMANDS list is all the items that will be in our options menu. Green stuff doesn't show up - it's only a "comment" in the code for us to remember what's going on.

The COMMANDS list is all the items that will be in our options menu. Green stuff doesn’t show up – it’s only a “comment” in the code for us to remember what’s going on.

This is a list of all of the commands that will appear in your options menu. We briefly encountered it in our last tutorial when we activated “:switch_1”, our profanity filter command. But you can see all of the others here too. To disable them, simply add a # in front. The line will turn green to indicate it’s been commented out, and is no longer active. For us, we want to disable the window commands, and the animations one as well.

Now with the stuff we don't like "commented out."

Now with the stuff we don’t like “commented out.”

Easy peasy. When we launch our menu, those options will no longer be present.

Our menu, without giving the player the option to mess with our pristine design

Our menu, without giving the player the option to mess with our pristine design

Spacing Out Options

Looking at this menu, “Instant Text” and “Profanity Filter” are both about the text. It makes sense to group them. But auto-dash? It has nothing to do with the other two. Visually, I’d like to separate it from the dialogue-related group of options, and move it below the other two as well.

The COMMANDS list that we just looked at sets the order of our options. It’s as simple as moving the line

:autodash,

to underneath where we handle our profanity filter. Make sure you take the : and the , with you – both are important.

Spacing is also done in our COMMANDS list. You should already see some lines that read:

:blank,

Those lines are creating the spaces you already see in the options list. Add one before our “autodash”, and the whole script should look like:

Changing the order here changes it in-game. Adding the "blank" line adds a space - use liberally to avoid clutter or menu busy-ness

Changing the order here changes it in-game. Adding the “blank” line adds a space – use liberally to avoid clutter or menu busy-ness

And, in game, our menu now looks like:

Reordered, respaced. Perfect.

Reordered, respaced. Perfect.

Bringing Back Game End

The next thing we want to do is not have our system menu replace game end, just serve as a different option. Heads up: if you’re doing this, you should disable “to_title” and “shutdown” in the Options Menu – you already know how to do that! (It’s the first thing we did above!)

We have three steps here. First, edit Yanfly’s script so it doesn’t takeover Game End. Second, tell the “Scene” for our menu what an options command would do. Third, tell the menu “Window” to draw a command for options.

1. Editing Yanfly’s Script

Head to the Yanfly’s System Options script we’ve been working with, and around line 251 you’ll see something labeled Vocab. It looks like:

VOCAB is just a way of having a central place to change the display name of things. But we don't need this anymore.

VOCAB is just a way of having a central place to change the display name of things. But we don’t need this anymore.

What this section is doing is replacing whatever you call GAME END in your game with SYSTEM. We don’t want that. Delete everything from module to end – here, lines 255 to 264. All deleting this does is return the vocab to normal – if you go try your game now, you’ll notice Game End still brings up the Options Menu.

Next, head to around line 888 looking for the script that overwrites the method “command_game_end”. It looks like:

The main culprit - this is what intercepts and replaces the Game End menu.

The main culprit – this is what intercepts and replaces the Game End menu.

Anytime the Game End menu option is called, RPG Maker expects to open the menu that allows you to go back to the title screen, or exit entirely. What Yanfly has done is stepped in and redirected RPG Maker to his screen. Basically, anytime something asks for Game End, Yanfly interrupts it and says “take this options menu instead.”

To remedy this, change the line:

def command_game_end

to

def command_opts

Now we’re no longer stealing Game End, but instead just using our own separate and unique command – it’s one called “opts.” We’ll be referring to it later.

We’re done in Yanfly, let’s head to…

2. Editing Scene_Menu

On the left side of your scripts list, under “Scenes” you’ll notice a file called “Scene_Menu.”

Each menu has a Scene, it's what's responsible for processing all of the button commands.

Each menu has a Scene, it’s what’s responsible for processing all of the button commands.

This is what creates the menu screen. Incidentally, if you don’t want to allow the player to access things like the equipment menu, here’s where to disable access.

Towards the top, you’ll see a function called “create_command_window” with all of the commands you see in the in-game menu. Wherever in that list you’d like your options menu to go, add:

@command_window.set_handler(:opts,      method(:command_opts))

Notice our :command_opts? That’s what we just made in Yanfly’s script. So what this is going to do is add an extra line in the menu. It’s internal name is “:opts” (don’t worry, we set the display name elsewhere), and when selected, it calls “command_opts” – the thing we already took care of in step one.

Our new addition uses the command we renamed in Yanfly, and an internal name, ":opts"

Our new addition uses the command we renamed in Yanfly, and an internal name, “:opts”

We’re done here, the last step is in…

3. Window_MenuCommand

The home stretch, just two things to do here. First, make a function that shows our Options Menu in the list. You can put this anywhere in the script outside of another function. And it reads:

def add_opts_command
    add_command("Options", :opts)
end

The first part in quotes is what the display name is. So if you want it to be “System” or “Audio” or whatever, feel free. The second part, :opts, is our internal name for this command that we set in step two.

A simple function, patterned off all the others around it. All this does is add a button, but we still need to call it every time the menu is launched...

A simple function, patterned off all the others around it. All this does is add a button, but we still need to call it every time the menu is launched…

Finally, head to the top of the script and look for the function “make_command_list” – add the command you just created there.

In addition to adding all the other commands, our main menu will now also add our "Options" one.

In addition to adding all the other commands, our main menu will now also add our “Options” one.

That’s it! Take it for a spin, and let’s see what we have in-game:

Our menu, in all its glory.

Our menu, in all its glory.

Simply stunning. Now we have our Options Menu, but we’ve also clearly marked the exit for players desperate to quit our game (not that they ever would want to, of course!)

There’s still so much functionality to build, but we’re getting there!

Advertisements

2 thoughts on “An Options Menu – Part II

  1. Pingback: An Options Menu – Part IV | The Iron Shoe
  2. Pingback: An Options Menu – Part V | The Iron Shoe

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s