how to shut down game but not shut down again after restarting (Oneshot style)

Hello all! This is my first post here. 🙂

I´ve used RPG maker MZ for about six months now. It´s my first real game planning engine. Never really learned writing code so this program is a saving grace for people like me who really want to make a game but get overwhelmed by programming. Still, I have already succeeded at making quite much with event tricks (like having an event follow players that triggers attack which enables old school Zelda -like attacking) and I´ve made "protect a friend" mission where you push attackers away for 1 minute to win the scenario.

Anyway for the question:
how to shut down game but not shut down again after restarting? This kind of thing is used a lot in games like OneShot.

Logically, event x should trigger both game save and shutdown (with this I have succeeded thanks to: SceneManager.exit();
BUT with my lacking in programming skills I haven´t figured out how to skip the shutdown again after loading save file.

This subject probably has been here already, so sorry if this is asking the same thing.

Thanks for your time anyway 🙂
saving the game and return to title screen I presume is one thing,
exit closes the game, when saving when dieing continue on that
spot, unless you load a common event first before that happening
on saveLoad?
Hmm, I´n not sure if I understood:
What I was thinking of doing (again, technically probably close to OneShot shutdowns) is to trigger an event (like talking to someone or getting an item) that both saves the game and shuts it down.
And when you reopen the game you will get an cutscene and the game processes on after that cutscene.

I did some googling and some people have had similiar problem which they tried to fix with some weird timer things.
Other solutions we´re having the load savefile function trigger something that (if I understood correctly) bypasses the event which triggered the shutdown in the first place.
I'd need to test it to be sure, but my first attempt would be to call
JavaScript:
$gameTemp.doShutdown = true;
before you save the game.

After the game is saved, you'd use a conditional branch to check for the following script:
JavaScript:
$gameTemp.doShutdown
and only shut down the game from inside that conditional branch.

Since $gameTemp does not get saved, creating a variable within and setting it to true before saving would allow you to check if that variable is still true afterwards, so you can shut down the game.

When you load the save, the variable no longer exists (since it was never saved) and the line of code that sets it won't get executed again (because it's already been executed). Thus the variable is no longer true and the game won't shut down.
trigger an event (like talking to someone or getting an item) that both saves the game and shuts it down.
And when you reopen the game you will get an cutscene and the game processes on after that cutscene.
So this is my confusion (and I suspect for other people - I don't know how many people have played Oneshot, I've never heard of it).

When you talk about "reopening the game," are you talking about running the game executable again, or about loading that save file?

So scenario one (which Nolonar gave you a solution for): The game saves your progress and kicks you out of the game (why exactly do you want this? As a player, it sounds annoying). You go to the normal title menu, load your game, and continue playing.

Scenario two (what I originally thought you were asking): The game saves your progress and completely closes. You run the game again, and you don't get the normal title menu, you immediately resume your save with the cutscene and stuff.
Thanks to both of you. I am mostly meaning that the game would completely shut down.
I can imagine it being annoying if it is used too much, but as a spice to making a "rare effect" seem even stronger, I can imagine it might be just the thing a few scenarios need.

And after you reopen the game the game intro would be altered a bit (optional little spice also).

Thanks you both for your ideas and replies. I will try Nolonars solution and see if it works 🙂
I am mostly meaning that the game would completely shut down.
And after you reopen the game the game intro would be altered a bit (optional little spice also).
So Nolonar's answer will shut down the game, but won't do anything for changing the title menu when you start it up again. For that, you'll need to look at the plugins that deal with New Game+/metadata things.
I can imagine it being annoying if it is used too much, but as a spice to making a "rare effect" seem even stronger, I can imagine it might be just the thing a few scenarios need.
I can't imagine a situation where I'm not annoyed by a game shutting itself off and expecting me to run it again (I would probably just go do something else instead). But if you have an artistic vision, run with it!
Sorry for doublepost.


I tested Nolonars suggestion and it worked perfectly. 🙂 Thanks you so much, this helped me a lot on two ways:
I understand RPG maker a little better and my game development is progressing


Edit: ATT_Turan
Also thanks to you
"So Nolonar's answer will shut down the game, but won't do anything for changing the title menu when you start it up again. For that, you'll need to look at the plugins that deal with New Game+/metadata things."
Yea, obviously I have to go deeper into that aspect as well.
For now I just moved main character do a different map with that script so there is no change to shut down the game again with the same event.

Original thread: https://forums.rpgmakerweb.com/threads/how-to-shut-down-game-but-not-shut-down-again-after-restarting-oneshot-style.140902/