19 October 2010

Customizing Menus - Part 3: Nuts and Bolts

In Part 1, we dealt with the basic menu structure and how the the commands are displayed and called. Part 2 detailed how to execute the routines when the menu item is selected. And Part 3 will continue with some of the other elements in the menu.

Immediately below the menu index (line 28 in RMXP and line 62 in RMVX) is the part to check if the party members (actors in RMXP or members in RMVX) are alive which sections can be displayed and if save is enabled display it in the menu options.

The code structure is as follows:


# If number of party members is 0
if $game_party.actors.size == 0
   # Disable items, skills, equipment, and status
# If save is forbidden
if $game_system.save_disabled
   # Disable save


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
if $game_system.save_disabled # If save is forbidden
   @command_window.draw_item(4, false) # Disable save

This queries whether any or all of the party members are incapacitated or dead, and disables the corresponding sections for them so that they are inaccessible through the menu. And if the save option is disabled (by setting @save_disabled to "true" in Game_System) then it will be grayed out in the menu.

The menu also contains a separate window to display the amount of gold (Window_Gold), with RMXP having two additional windows for the number of steps (Window_Steps) and the amount of time played (Window_PlayTime.) These are placed in main directly under the above in RMXP, but are placed in start in RMVX. Note that if you add to the menu, it might overlap these windows so changing their y values will push them down.

When adding additional windows, don't forget to update them under the "Frame Update" method and dispose of them under the "Main Loop" (starting line 75 in RMXP) and the terminate method in RMVX.

This tutorial outlines the basics of the menu only and provides a simple method of adding new menu items. For further simplicity, I would highly recommend SojaBird's New Menu Item as it allows you to add new items to the menu without having to directly modify the code as detailed in this tutorial.

0 Comments So Far:

Post a Comment

Related Posts with Thumbnails
Template Design "Perfect World" by SkinCorner