Home > Tutorials > Ruby Game Scripting System 2 > RMVX Basic Menu Customization
RMVX Basic Menu Customization 
The Problem:
The RGSS2 Menu system is frustrating for scripters (and developers) because it is not built in a way that makes it possible to just "add" onto the existing menu. Every script that changes the menu will include only the menu items that particular script uses, rather than accumulating all the new menu items from all the previous scripts in a project.
This means, if you want to get multiple scripts working together you either need to use a new menu framework script OR modify the existing Scene_Menu to work the way you want.
The Solution:
There are 2 steps in this process:
- Change the text of the menu items
- Change the commands of the menu items
Step 1: Change the text of the menu items
For this, we are concerned with the create_command_window method definition of the Scene_Menu class. The first thing to notice is the list of variables that start with "s":

Each one of these variables holds the text from the right-hand side of the equal sign. So, to change the text of one of the existing menu items, just change the stuff on the right side of the equation. You can use predefined terms from the vocab module like they did, or you can use string literals or other variable types as long as you convert them to a string using the .to_s method:
Valid Assignments:
Code:
#Vocab Property
s1 = Vocab::item
#String literal (notice the quotations!)
s1 = "Items"
#fixnum converted to a string
s1 = 12345.to_s
#fixnum assigned to a variable, variable converted to a string
myNumber = 12345
s1 = myNumber.to_s
Invalid Assignments:
Code:
#don't use a vocab property that doesn't exist!
s1 = Vocab::somthingThatDoesntExist
#don't leave off the quotes!
s1 = Items
#don't forget to convert to a string!
s1 = 12345
This is also where you want to add any new items you want to see in your menu. Simply add another "s" variable for your new menu item. You should assign the variables in the order you would like them to appear to keep things simple. For instance, if you were using my ACS and ClassSwitcher scripts, you might put them in this order (I included Vocabs in both these scripts!):
Code:
s1 = Vocab::item
s2 = Vocab::skill
s3 = Vocab::equip
s4 = Vocab::status
s5 = Vocab::classes
s6 = Vocab::crafting
s7 = Vocab::save
s8 = Vocab::game_end
Almost done! now we need to edit the next line a little:

This line creates the window that actually displays our menu items. You can see our "s" variables are in the brackets near the end of the line. If you added any new s variables, you need to add them to this line or you won't be able to see them in the menu! Likewise if you removed anything, you'll need to remove it from this line to keep it from showing up. So sticking with our previous example, we have to add the 2 new "s" variables we created:
@command_window = Window_Command.new(160, [s1, s2, s3, s4, s5, s6, s7, s8])
see, easy! Now the menu will properly display our items! Time to make the menu actually do something when we click them!
Step 2: Change the commands of the menu items
Now we are concerned with the update_command_selection method of the Scene_Menu class. We need to change the code so that it does the right thing when we click on each menu item. This is the part of the code that handles the execution of each menu item:

This can be confusing so let me explain: Each item in the menu has been given a "number" in the order that they are listed. It starts with 0 instead of 1 and counts up; so 0 is item, 1 is skill etc. For each menu item, you need a corresponding "when X" entry, followed by the code to execute when that menu item is selected by the player. So, looking at the code that's already there, when I select the "Items" entry in the menu, it runs the code under "when 0" which is: $scene = Scene_Item.new. You'll also notice that they grouped 1,2 and 3 together since they execute the same command when clicked. To edit this you need to find the right command to run for the menu item from your added scripts. In ACS, the command is $scene = Scene_Crafting.new and in ClassSwitcher it is the same as skill, equipment and status: update_actor_selection. You need to add the new "when" between the "case" and the next "end", but for simplicity just try to keep the "when"s in order(even though you don't have to)! Here's how we would add the new "when"s for ACS and ClassSwitcher:
Code:
case @command_window.index
when 0 # Item
$scene = Scene_Item.new
when 1..4 # Skill, equipment, status, class
start_actor_selection
when 5
$scene = Scene_Crafting.new
when 6 # Save
$scene = Scene_File.new(true, false, false)
when 7 # End Game
$scene = Scene_End.new
end
You probably noticed the funky ".." at "when 1..4". This is one way to specify a range of values, so it's the same as saying "when 1,2,3,4". I do it because I'm too lazy to type the extra 3 characters the other way. :lol:
So in a perfect world, after you've made this edit your menu should work! Unfortunatly, in ClassSwitcher, because I re-used the update_actor_selection method, you would also have to edit that! It is similar to what we just did; it adds another "when" statement to the "case". Here is the full code:
Code:
def update_actor_selection
if Input.trigger?(Input::B)
Sound.play_cancel
end_actor_selection
elsif Input.trigger?(Input::C)
$game_party.last_actor_index = @status_window.index
Sound.play_decision
case @command_window.index
when 1 # skill
$scene = Scene_Skill.new(@status_window.index)
when 2 # equipment
$scene = Scene_Equip.new(@status_window.index)
when 3 # status
$scene = Scene_Status.new(@status_window.index)
when 4 # classes <-----THIS IS WHAT I ADDED!
$scene = Scene_Class_Switch.new(@status_window.index)
end
end
end
Note that the numbers match the ones above for this command (1 through 4). I will probably change this in the next update to make it more compatible with other scripts and lessen the work you'd have to do to customize your menu, but you may have to make similar changes for other scripts!
So where do I make these modifications?
I'm glad you asked! Of course you can always edit the existing Scene_Menu but odds are high that the scripter already redefined them, so your changes will be overwritten by your scripts farther down the list! I highly suggest you place a new file at the END of the materials section. Start with the Scene_Menu class name:
Code:
class Scene_Menu < Scene_Base
end
Then copy and paste the create_command_window method and the update_command_selection method inside the class:
Code:
class Scene_Menu < Scene_Base
#--------------------------------------------------------------------------
# * Create Command Window
#--------------------------------------------------------------------------
def create_command_window
s1 = Vocab::item
s2 = Vocab::skill
s3 = Vocab::equip
s4 = Vocab::status
s5 = Vocab::save
s6 = Vocab::game_end
@command_window = Window_Command.new(160, [s1, s2, s3, s4, s5, s6])
@command_window.index = @menu_index
if $game_party.members.size == 0 # If number of party members is 0
@command_window.draw_item(0, false) # Disable item
@command_window.draw_item(1, false) # Disable skill
@command_window.draw_item(2, false) # Disable equipment
@command_window.draw_item(3, false) # Disable status
end
if $game_system.save_disabled # If save is forbidden
@command_window.draw_item(4, false) # Disable save
end
end
#--------------------------------------------------------------------------
# * Update Command Selection
#--------------------------------------------------------------------------
def update_command_selection
if Input.trigger?(Input::B)
Sound.play_cancel
$scene = Scene_Map.new
elsif Input.trigger?(Input::C)
if $game_party.members.size == 0 and @command_window.index < 4
Sound.play_buzzer
return
elsif $game_system.save_disabled and @command_window.index == 4
Sound.play_buzzer
return
end
Sound.play_decision
case @command_window.index
when 0 # Item
$scene = Scene_Item.new
when 1,2,3 # Skill, equipment, status
start_actor_selection
when 4 # Save
$scene = Scene_File.new(true, false, false)
when 5 # End Game
$scene = Scene_End.new
end
end
end
end
Then apply your edits! If you've updated everything necessary, you should have a working menu!
This concludes the Menu Editing tutorial. Now, go forth and make awesome games :D
|
|
Details
|
|
Tutorial:
|
RMVX Basic Menu Customization |
|
Date Listed:
|
Tue, 17 Jun 2008 05:46:33 -0700 |
|
Author:
|
cmpsr2000
|
|
Total Hits:
|
13656 |
|
|