RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
[Scripting - RGSS2] Adding New Options on the RMVX Menu

0 Members and 1 Guest are viewing this topic.

**
Rep:
Level 84
Adding New Options on the RMVX Menu
by:Rafidelis™ | 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:

Spoiler for:
Code: [Select]
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)

Your menu will look like that:

Menu with a new option:

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 [color="red"]160[/color]:

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

_________________________________________________________________________________________ __

_________________________________________________________________________________________ __

Spoiler for:
Code: [Select]
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"?

Spoiler for:
? 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)

Spoiler for:
Answer : ? On 5
?   Go to the end game screen

_________________________________________________________________________________________ __



Past the script below the one you have already pasted.

_________________________________________________________________________________________ __

_________________________________________________________________________________________ __


Spoiler for:
Code: [Select]
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:


_________________________________________________________________________________________ __

Spoiler for:
1.   
Code: [Select]
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.
Spoiler for:
   
Code: [Select]
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: [Select]
$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:


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 :

Spoiler for:
Code: [Select]
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
[/font]

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
Nice, detailed tutorial for the non-scripter. Good work rafidelis.

**
Rep:
Level 84
Thankz modern Algebra^^
I'm translating a tutorial to post more later ^ ^

**
Rep: +0/-0Level 80
RMRK Junior
helpd me heepz tnx ;D ;D ;D ;D
Nobody is perfect, therefore i am Nobody


Spoiler for:
Cna yuo raed tihs? Olny 55% of plepoe can.
I cdnuolt blveiee taht I cluod aulaclty uesdnatnrd waht I was rdanieg. The phaonmneal pweor of the hmuan mnid, aoccdrnig to a rscheearch at Cmabrigde Uinervtisy, it dseno't mtaetr in waht oerdr the ltteres in a wrod are, the olny iproamtnt tihng is taht the frsit and lsat ltteer be in the rghit pclae. The rset can be a taotl mses and you can sitll raed it whotuit a pboerlm. Tihs is bcuseae the huamn mnid deos not raed ervey lteter by istlef, but the wrod as a wlohe. Azanmig huh? yaeh and I awlyas tghuhot slpeling was ipmorantt!
fi yuo cna raed tihs, palce it in yuor siantugre.


Click here to feed me a !
Get your own at Pokeplushies!


Click here to feed me a !
Get your own at Pokeplushies!


Click here to feed me a !
Get your own at Pokeplushies!