How to script a simple return to the last scene? Newbie Rpgmakervxace user

Hi! I'm totally new on Rpg Maker VX Ace when it comes to scripting, anyway when I was writing a common event script, I came up with a small disappointment with it, because there isn't any built-in command for "Open Item View". So I used the "open meny screen" command (see screenshot) which works but don't give the effect i'm aiming for. So I thought there must be a way to script a code to return to the last screen used before calling the common event (which in this case i called when using a item).?
Anyone kind person wanna point me in the right direction? 🙂

 

screenhelp.png
Use this:

Code:
SceneManager.return
It just killed everything?! It turned off the running instance of the game. Any idea why?
Do you want to open the Item Menu?


if so then add a script command in your common event


under advanced > script..


then type


SceneManager.call(Scene_Item)
Thx alot kaisei ! 🙂 it worked
I'm glad it helped, regarding about the Last Scene used.


You can try to add this line to Script>Scenes>Scene_Base


around line 110 def return_scene


$game_variables[n] = SceneManager.scene.class


n will be the number for your variable ex: $game_variables[1]


just choose an unused variable.


It'll look like this :


def return_scene


$game_variables[1] = SceneManager.scene.class


SceneManager.return


end


Then open your common event then add script :


SceneManager.call($game_variables[n])


I tried this and no problems so far.


Well if my previous solution answered your query then disregard this.
The last one worked thanks 🙂

So if i want another screen i could mark it with a variable?
Great, it worked.


I think you can only have 1 active scene.


Why would you need another one?


The variable method is for the Last Scene opened so


if you need a specific scene then just call it directly through script.


You can see all availble scenes in Script>Scenes so just choose which one you like for specific calls.


I'm fairly new to Ruby too, so I might be mistaken.
Okay thanks i will test it out 🙂
Well, you could just replace all this code with variables and stuff and just use SceneManager.return. The game instance may have closed because you didn't call any scene before calling it, so it returns to a null scene and you know what's after.


Indeed, SceneManager.return does exactly the same thing as all this code, but without wasting a game variable...


If you still don't want to use SceneManager.return, at least don't waste variables:

Code:
SceneManager.call(SceneManager.instance_variable_get(:@stack).pop || SceneManager.scene)
This call will also prevent the game of closing even if you forget to call any scene before it.
SceneManager.call(SceneManager.instance_variable_get🙂@stack).pop || SceneManager.scene)I have no idea what that mean, could you comment it out for me?

Original thread: https://forums.rpgmakerweb.com/threads/how-to-script-a-simple-return-to-the-last-scene-newbie-rpgmakervxace-user.50079/