- RafidelisMembre
- Nombre de messages : 55
Distinction : aucune
Date d'inscription : 01/05/2008
[Scripting - RGSS2] Adding New Options on the RMVX Menu
Jeu 22 Jan 2009 - 21:15
___________________________________________________________________________________________
___________________________________________________________________________________________
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:
- 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:
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:28d6="red"]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
___________________________________________________________________________________________
___________________________________________________________________________________________
- Spoiler:
- 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 [color:28d6="red"]0 and the cursor is shorter than 4
○ If the command window is shorter than [color:28d6="red"]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.
◘ [color:28d6="blue"]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:
- ◘ 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:
- Answer : ◘ On 5
○ Go to the end game screen
___________________________________________________________________________________________
Past the script below the one you have already pasted.
___________________________________________________________________________________________
___________________________________________________________________________________________
- Spoiler:
- 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:
___________________________________________________________________________________________
- Spoiler:
- 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.
- Spoiler:
- [code=text]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[/code]
___________________________________________________________________________________________
___________________________________________________________________________________________
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:
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 ([color=blue]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:
- [code=text]when 6
$scene = Scene_End.new[/code]
___________________________________________________________________________________________
___________________________________________________________________________________________
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 comments 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
Re: [Scripting - RGSS2] Adding New Options on the RMVX Menu
Jeu 22 Jan 2009 - 21:55
Thanks !
Very usefull !
this tut gonna help lots of guys !
Very usefull !
this tut gonna help lots of guys !
- RafidelisMembre
- Nombre de messages : 55
Distinction : aucune
Date d'inscription : 01/05/2008
Re: [Scripting - RGSS2] Adding New Options on the RMVX Menu
Ven 23 Jan 2009 - 0:36
Thankz berka^^
- Coco'Staffeux retraité
- Nombre de messages : 6578
Age : 31
Localisation : Nord/Douai
Distinction : EL DICTATOR COCO'
Coco-Dieu en puissance
Grand gourou suppléant de la secte des MAGIKARP
Leader charismatique des 2beStaffieux
N°1 du forum
Président, vice-présidents et membres honoraires de la cour suprême du forum
Président de l'association des grosses distinctions CMB
Date d'inscription : 02/07/2008
Re: [Scripting - RGSS2] Adding New Options on the RMVX Menu
Ven 23 Jan 2009 - 19:58
Oh! Thanks a lot Rafidelis! :o
This tutoriel is going to serve me a lot in the learning of the RGSS language!
This tutoriel is going to serve me a lot in the learning of the RGSS language!
- Spoiler:
- Excuse me for my poor english, I can speak very well english in oral discussion but by writing...
- RafidelisMembre
- Nombre de messages : 55
Distinction : aucune
Date d'inscription : 01/05/2008
Re: [Scripting - RGSS2] Adding New Options on the RMVX Menu
Dim 15 Fév 2009 - 16:16
Merci pour les commentaires des amis ^ ^
Re: [Scripting - RGSS2] Adding New Options on the RMVX Menu
Dim 1 Mar 2009 - 15:27
J'espère que ce n'est pas du nécro-post mais, le menu des options n'est pas terminé...
Il met ça:
Si ce n'était qu'un tutoriel alors je me tais... mais c'est dommage...
Il met ça:
- Spoiler:
Si ce n'était qu'un tutoriel alors je me tais... mais c'est dommage...
Re: [Scripting - RGSS2] Adding New Options on the RMVX Menu
Dim 1 Mar 2009 - 15:33
ce tuto ne fait qu'indiquer comment rajouter les options dans le menu, pas leur contenu !
Re: [Scripting - RGSS2] Adding New Options on the RMVX Menu
Dim 1 Mar 2009 - 15:43
Ok...
Merci bien...
Ça reste un super tutoriel !
Merci bien...
Ça reste un super tutoriel !
Permission de ce forum:
Vous ne pouvez pas répondre aux sujets dans ce forum