RMMV How to have the cursor on a different option of the menu by default.

Magusalfador

AKA VaroClaw
Veteran
Joined
Jun 15, 2014
Messages
265
Reaction score
43
First Language
English Spanish
Primarily Uses
RMMV
Hi all!

Im doing some tutorials and i would like to open my main menu and have the cursor selecting another option of the menu, not the first one(index 0 i suppose?) So if my menu is Inventory, skills, tutorials and save. Instead of opening my menu and having the cursor on inventory, I would like to have the cursor selecting tutorials.

thanks!
 

Zevia

Veteran
Veteran
Joined
Aug 4, 2012
Messages
647
Reaction score
358
First Language
English
Primarily Uses
RMMV
If your window extends Window_Selectable, it should have a default select method that you can pass an index to. The default logic often has a method called selectLast or reselect that will store the index of a given window when it was last used to reselect that index.

You should be able to do something like:
JavaScript:
SceneManager._scene._commandWindow.select(1);

Since you mentioned the menu, I'm assuming you're in the Menu Scene (Scene_Menu), which has:
  • Window_MenuCommand (the window that lets you select a command)
  • Window_Gold (the window showing how much gold you have)
  • Window_MenuStatus (the status of your party)
They're stored on the scene as the properties:
  • _commandWindow
  • _goldWindow
  • _statusWindow
I'm not sure if there's a more canonical or appropriate way to reference the current scene, but I've always just gone with SceneManager._scene. So if you're doing a tutorial and you wanted to open the menu, then select a command, you could have something like:
JavaScript:
SceneManager.goto(Scene_Menu);
SceneManager._scene._commandWindow.select(1); // Where 1 is the index of what command you want to select
 

Magusalfador

AKA VaroClaw
Veteran
Joined
Jun 15, 2014
Messages
265
Reaction score
43
First Language
English Spanish
Primarily Uses
RMMV
@Zevia I get the error ##Uncaught TypeError: Cannot read property 'select' of undefined##

I thought it was because im using moghutner plug in which im sure it overwrites the scene_menu. But I tried it on a a new project and it still gives me that error.

But what you are saying makes a lot of sense.

I copy pasted your code :
Code:
SceneManager.goto(Scene_Menu);
SceneManager._scene._commandWindow.select(1);

Was i supposed to change something, besides the index I want?
 
Last edited:

Zevia

Veteran
Veteran
Joined
Aug 4, 2012
Messages
647
Reaction score
358
First Language
English
Primarily Uses
RMMV
Hmm. Code works fine for me in a new project:
gotoscene.PNG
gotoscenesuccess.PNG
select1.PNG

I'm using RPG Maker MV - are you on MZ? Perhaps the API changed a bit from one version to the other.
 

Magusalfador

AKA VaroClaw
Veteran
Joined
Jun 15, 2014
Messages
265
Reaction score
43
First Language
English Spanish
Primarily Uses
RMMV
Lol. Im dumb. I was running both lines at the same time. It works!!

thank you!!!
 

Zevia

Veteran
Veteran
Joined
Aug 4, 2012
Messages
647
Reaction score
358
First Language
English
Primarily Uses
RMMV
Ah - if you need to run both lines back to back (that is, you'd like the menu to open and as soon as it does, immediately select a different option), you can modify one of the Scene_Menu methods. Probably create or start or something like that, I'd have to look a bit and tinker. It's a problem with what's known as asynchronous execution since RM runs on an event loop and goto just tells the SceneManager to change scenes at the next available opportunity.

Otherwise, if what you have already works, then great!
 

Latest Threads

Latest Posts

Latest Profile Posts

Just spent $174 on Shining the Holy Ark on the Saturn. Good lord.
My brain when designing quests:
There is piano, it needs help --> The organ (yes organ now) is missing a component! --> Where the heck am I supposed to put this missing piece!??! --> Add an entire new mini dungeon specifically created to house this new piece. --> Connect this brand new mini dungeon to an already designed dungeon with background information about the town it's found it.

Me: :LZYhuh:
Rising of the Shield Hero!
Sheesh, Guys, don't think you can throw easy prices like $25/$50 on potions/ethers then have monsters pay you $75 for killing them (never understood that concept btw lol) and think it'll all work out!!! Just realized my prcies vs payout left my players unable to get decent stuff without some serious farming from the start, i'm about to call H&R Block to help my MC get his stimulus check just to buy new armor :LZSlol:

Forum statistics

Threads
111,095
Messages
1,058,211
Members
144,285
Latest member
sleepyfrog
Top