Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

[-Scripting- RGSS2]Adding New Options on the RMVX Menu

Adding New Options on the RMVX Menu
by:Rafidelisâ„¢ | http://www.ReinoRpg.com |


___________________________________________________________________________________________

___________________________________________________________________________________________

Well people, I decided to make this tutorial for whose that want to modify the default menu optior or add new options there.

Let's begin:

___________________________________________________________________________________________


First, open your project or create a new one then press F11 to the scripts editor show up. After that create a new script section by pressing the mouse right button over main and choosing the insert option.

On the new script section, copy and paste the code below:

Code:
 class Scene_Menu < Scene_Base

  def create_command_window

    s1 = Vocab::item

    s2 = Vocab::skill

    s3 = Vocab::equip

    s4 = Vocab::status

    s5 = Vocab::save

    s6 = Vocab::game_end

    s7 = "Options"

    @command_window = Window_Command.new(160, [s1, s2, s3, s4, s5,s7, s6])

    @command_window.index = @menu_index

    if $game_party.members.size == 0          # If there isn't any party members

      @command_window.draw_item(0, false)    # Disable "Items"

      @command_window.draw_item(1, false)    # Disable "Skills"

      @command_window.draw_item(2, false)    # Disable "Equipments"

      @command_window.draw_item(3, false)    # Disable "Status"

    end

    if $game_system.save_disabled            # If saving is forbidden

      @command_window.draw_item(4, false)    # Disable "Save"

    end

  end 

end


Explanation of the script above:


Firstly acess the class Scene_Menu,then we are going to "rewrite" the method
create_command_window.
First you should create 7 local variables, which one storing a value.

s1 = Vocab::item

It means that this variable will have the value of the vocabulary used to name the window.
(Which can be modified on the database, on the system tab),if you write the name:

Item bag, The variable s1 will have the value of the string "Mochila de Itens"

The same occurs with the other variables, except the s7 which you you gave it's own name, in that case it's "Options".
On line 10 we create an variable named:

@command_window and it's values are:

Window_Command.new(160, [s1, s2, s3, s4, s5,s7, s6])

Window_Command is the class responsable for creating the script where you can
choose an option, here the options are the values stored on the 7 lacals variables
shown above.( 160 in the window width in pixels!)
On line 11 we determine that the "index",the window indicator(cursor) will start
on the defined variable @menu_index which by default is 0 (Itens).

But from line 12 till 16,determines that if the size of the group "heros" is equal to 0, it'll disable
the following options: Itens,Skills,Equipments and Status(As there won1t be any hero)

na linha 17,ele checa se o save esta desativado no jogo,se estiver desativa a opção de Salvar o Game.
Assim termina esse codigo,nada muito complicado ne?


Your menu will look like that:

Menu with a new option:
ss1hl8.png


OBS: The line 53 to 71 on the default rmvx scene_menu script, you'll see
that it's very similar to what we have just writeen.

___________________________________________________________________________________________


Now paste the script we have written and open the menu,you'll that the option “Options” is there on the menu, now click on it.
What happened?

The game over scene appeared when we clicked on the option “options”, but why?

I'll explain soon,but now turn back to the menu and click in the option “Exit”,You will see that nothing happens.

Which option on the menu has it's own “index”,that is, an indicator.

When the index is on 0 it will open the itens scene, on 1 the skill scene, on 2 the equipment one, on 3 the status one and if it is on 5 it will open the game over screen.

Take a look at the “array” that contains the menu options:

@command_window = Window_Command.new(160,[s1,s2, s3, s4, s5,s7, s6])

Lets start counting the "index" of that “array” after the 160:

s1 = 0
s2 = 1
s3 = 2
s4 = 3
s5 = 4
s7 = 5
s6 = 6

Before doing anything, remove the last "end" of the code we created at the start.
Now we will see the method that creates the action depending on our index value:

Obs.: Don't put the code below our script

___________________________________________________________________________________________

___________________________________________________________________________________________

Code:
 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  # Habilidades, equipamento, status

        start_actor_selection

      when 4      # Salvar

        $scene = Scene_File.new(true, false, false)

      when 5      # Fim de jogo

        $scene = Scene_End.new

      end

    end

  end

___________________________________________________________________________________________

This code can be read like that:

• If buttom B is pressed (esc or x) play an SE and return to the map scene.
â—‹ But if if button C(Enter or space)
â—‹ And inside this condition if the group equals 0 and the cursor is shorter than 4
â—‹ If the command window is shorter than 4 plays an error SE.
â—‹ Still inside the condition press button : But if save is disabled and
â—‹ if the command window cursor is equal, plays an SE and returns.
â—˜ End of the condition

• If press button and none of the conditions above are true, plays an decision SE then continue.

• If the cursos is at:

â—˜ when 0
â—‹ Go to items window
â—˜ when 1 2 e 3
â—‹ Go to chose character window
â—˜ when 4
â—‹ Go to save game
â—˜ when 5
â—‹ Go to end game window
• end
• end
• end

Well what is the array of the indicator when it is over "options"?

â—˜ Answer : 5

And on the refresh of the cursor position when C is pressed (space or Enter) on the cursor 5?( Look at the code to see what happens)

Answer : â—˜ On 5
â—‹ Go to the end game screen

___________________________________________________________________________________________



Past the script below the one you have already pasted.

___________________________________________________________________________________________

___________________________________________________________________________________________


Code:
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  # Habilidades, equipamento, status

        start_actor_selection

      when 4      # Salvar

        $scene = Scene_File.new(true, false, false)

      when 5      # Fim de jogo

        $scene = Scene_End.new

      end

    end

  end

The script now should look like this:


___________________________________________________________________________________________

1.
Code:
 class Scene_Menu < Scene_Base

   def create_command_window

     s1 = Vocab::item

     s2 = Vocab::skill

     s3 = Vocab::equip

     s4 = Vocab::status

     s5 = Vocab::save

     s6 = Vocab::game_end

     s7 = "Options"

     @command_window = Window_Command.new(160, [s1, s2, s3, s4, s5,s7, s6])

     @command_window.index = @menu_index

     if $game_party.members.size == 0

       @command_window.draw_item(0, false)

    @command_window.draw_item(1, false)

    @command_window.draw_item(2, false)

    @command_window.draw_item(3, false)

    end

    if $game_system.save_disabled

    @command_window.draw_item(4, false)

    end

end

 

    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  # Skil,equip,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

___________________________________________________________________________________________

___________________________________________________________________________________________


Now we are going to edit the part that when the cursor is over 5 it will open the options window.
First we are going to create the script to show the option, paste the code below in a new script section.
Code:
class Scene_Option < Scene_Base

def initialize(indicador_inicial = 0)   

# Define that when we call the script, the index automatically be the 0

    @indicador_inicial = indicador_inicial

    end

 

    def start

    super   

    create_menu_background 

    criar_janela_deComandos_Options #Go to the method that creates a command window 

    end

 

    def terminate

    super

    dispose_menu_background

    @janela_deComando_Options.dispose

    end

 

    def update

    super   

    update_menu_background

  @janela_deComando_Options.update

    if Input.trigger?(Input::B)

    Sound.play_cancel

    print "Choose one of the options I turn off the option of Exit by Esc (kkkkkkkkkkk * Am I evil xD*)" 

    elsif Input.trigger?(Input::C)

    Sound.play_decision

    case @janela_deComando_Options.index

    when 0

    print "Try to create a scenes that the player can set the speed of the game = D"

    when 1

    print "I do not know if it is possible to decrease or increase the quality of the game graphic,Just added this option to have one more."

    when 2

    $scene = Scene_Menu.new(5)

    when 3

    $scene = Scene_Map.new

    end

    end

    end

 

    def criar_janela_deComandos_Options

    option1 = "Sound volume "

    option2 = "Quality of graphics"

    option3 = "Back to Menu"

    option4 = "Back To Map"

    @janela_deComando_Options = Window_Command.new(260,[option1,option2,option3,option4])

    @janela_deComando_Options.index = @indicador_inicial

    @janela_deComando_Options.x = Graphics.width/2 - @janela_deComando_Options.width/2

    @janela_deComando_Options.y = Graphics.height/2 - @janela_deComando_Options.height/2

    end

end

___________________________________________________________________________________________

___________________________________________________________________________________________

Now back to our script, the menu one and on line 44 change to the following code:

Code:
$scene = Scene_Option.new

Now run the game and choose the option "options" one the menu that is possible to access the options window created by us, get back to the menu and click on the exit option and you'll see that it only plays a SE but it's not working.
Why that?

Options screen:

rafidelisoq3.png


Because on the script that refreshs the cursor position we didn't indicated what happens if it is on the indicator "6",there is only till 5 (when 5)

For that open it on line 44 of our menu script, press enter go to the empty line that should be line 45 and paste there :

Code:
when 6

           $scene = Scene_End.new

___________________________________________________________________________________________

___________________________________________________________________________________________

Done! Your new option was added on rmvx menu!
Just post if you have any question! I'll be glad to answer it^^

Criticizing and comentários are welcome too xD


Tutorial by ::. Rafidelis .::


Thanks to a brazilian friend ~ JV ~, by translating the tutorial from Portuguese to English.
___________________________________________________________________________________________

___________________________________________________________________________________________



RGSS2 Tutorial Adding New Options on the RMVX Menu by Rafidelis is licensed under a
Creative Commons Atribuição-Uso Não-Comercial-Compartilhamento pela mesma Licença 2.5 Brasil License.
Permissions beyond the scope of this license may be available at ReinoRPG.com
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top