Resetting Game Progress with a new playthrough

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
Akuni
Regular
Posts: 40
Joined: Wed Dec 07, 2011 7:06 pm
Location: REDACTED
Contact:

Resetting Game Progress with a new playthrough

#1 Post by Akuni »

Basically I've set up an infinite loop in my game where after the player selects the 'Bad End' route they would revert back to the original choices to pick again. If they try to pick the 'Bad End' again, they won't be able to, and it'll loop dialogue until they pick the other one.

Now, I've set up the loop with the various variables and labels and its worked fine.

I want to make it so that if a player decided to replay the whole game again the variable from their previous playthroughs would be reset basically.

I've tried the

Code: Select all

            "END" 
            $ persistent._clear()
    return


and it didn't seem to work.

Here's everything I've set up so far.

At the outset:

Code: Select all

define CHARNME2 = DynamicCharacter('CHAR_Name', color="#298A08")
define Evl = DynamicCharacter('Cake_Name', color="#FE2E64")
define CHARNME = DynamicCharacter('CHAR_Name', color="#58FA58")
$ menuchoice1 = 0
$ menuchoice2 = 0
 
label start:
    menu:
        "Choose to play"
        "Side A":
            jump ACT_I_NM2
        "Side B":
            jump ACT_I_NM
    
label ACT_I_Tet:
        
    $ menuchoice1 = 0
    $ menuchoice2 = 0
    $ CHAR_Name = "NM" 
At the first_choice label:

Code: Select all

    label first_choice:

    Tet "W-wait~!"
    
    label same_options:
            menu:
                "Plead with Her":
                    if menuchoice1 == False:
                        $ menuchoice1 = True
                    jump wrong_choice            
                    
                "Persuade Her":
                    jump game_continue
                
        
    label wrong_choice:
            if menuchoice1 == 1:
                jump baka_desu
            
            else:
                
                "BAD END"
                
                Evl "Hey! I can't just let you kill us both off. Try Again."
                $ menuchoice1 += 1
                jump first_choice
            
    label baka_desu:
            Evl "Are you trying to get us killed?"
            Evl "Try Again."
            jump same_options
               
    label game_continue:
            
            "Gameplay goes on..."

I don't know if I messed up somewhere or something else. But I want to know what can I put at the end so that someone doing a second playthrough would be able to see the 'Bad End' route again, or is that not possible?
Last edited by Akuni on Mon Mar 13, 2023 8:24 am, edited 1 time in total.

User avatar
theCodeCat
Regular
Posts: 62
Joined: Sun Sep 06, 2015 8:40 pm
Projects: Lucid9, Mystic Destinies: Serendipity of Aeons
Skype: theCodeCat
Contact:

Re: Resetting Game Progress with a new playthrough

#2 Post by theCodeCat »

If the player starts their second playthrough from the main menu, then those state variables should automatically be reset.
Have you tried starting a second playthrough an seeing what happens?

User avatar
xela
Lemma-Class Veteran
Posts: 2481
Joined: Sun Sep 18, 2011 10:13 am
Contact:

Re: Resetting Game Progress with a new playthrough

#3 Post by xela »

Akuni wrote:But I want to know what can I put at the end so that someone doing a second playthrough would be able to see the 'Bad End' route again, or is that not possible?
It is very much possible but some stuff in your post is really weird.

1) *New Game (starting a new playthrough as you called it), you either have the player start a New Game properly as theCodeCat suggested and condition that menu of a persistent variable so that that bad end option never pops up again or:
2) Jump to a previous label as you do.but you prolly shouldn't call it "new/second playthrough".

Best I can tell, with your code setup you can just do something like:

Code: Select all

    label same_options:
            menu:
                "Plead with Her" if int(menuchoice1) <= 2:
                    if menuchoice1 == False:
and it will work but it will not "reset" all the variable unless you put them into that label you seem to be starting this sequence from.

====>>
I believe that you're thinking about this problem all wrong, you don't "reset" all variables to have something new happen or not happen on the next play through, you do the exact opposite, you change a variable and use it as a "flag" to control "gameflow". All other variables you'll have to reset, you can either do that by creating a label where you define all variables like:

Code: Select all

label my_default_vars:
    python:
        vat1 = False
        var2 = 2141
        var3 = "Apples"
    return
and call it when you require a reset but declare your "gameflow" variables somewhere prior to this call else or restart the game and use persistent data.

Difference between the two is that your variant (no new game) will make sure that if a New Game is trully started, people will see the bad choices again. Persistent data will make sure that the bad choice is never seen again, until the persistent is cleared, even if a new game is started properly.
Like what we're doing? Support us at:
Image

User avatar
sunwave
Regular
Posts: 45
Joined: Fri Apr 15, 2016 2:26 pm
Location: Netherlands
Contact:

Re: Resetting Game Progress with a new playthrough

#4 Post by sunwave »

Yes, at mentioned above, you will just have to call a label that resets all your persistent variables if you want to reset your game data. Do them manually, one by one. It gives the best result since you can reset them to their "default/beginning" states instead of just clearing them completely. This way, the game will always remember you did the bad end, until you reset the game data with a special button or something. (If you want to see a very simplified version, it's the 2nd block of code).

If you want the game to automatically forget when pressing new game, there is another way. You can do it like this:
Note: I get from your code that you want the menu choice to still pop up, but lead to the correct ending anyway, right? At least, that's what you did.

Code: Select all

label start:
    "Some scenes"
    "Time for the choice"

label first_choice:
    "Wut wut, what do I do now?"
    menu:
        "Plead with her":
            if var_badendseen = 1
                "You will get the good route anyway"
                jump good_scenes
            else:
                "Go to the bad end"
                jump bad_scenes
        "Convince her":
            "Continue game"
            jump good_scenes

label bad_scenes:
    "You will die"
    $ var_badendseen = 1
    "DEAD"
    jump label start # THIS WILL START FROM THE START OF THE GAME WITHOUT USING NEW GAME => Will keep variables even if not persistent.

label good_scenes:
    "Continue game from here"
Now, if you press "new game" from the menu, the game will forget all about you having seen the bad ending, and will just play it out as if it's the first time you've seen it.
So there is a difference between "new game" and "new playthrough without new game". Your post was very unclear about that.

If you want to have the player use the 'new-game' button for playthroughs WITH saved data as well, then you'll have to use persistent variables, as you did. Then it would become different. First of all, you'll need two new game buttons. One that just starts. And one that starts "with data reset" => for the "with data reset" you need to have the button set a variable. For example:

Pressed new game: (Start at label_start)
Pressed new game with reset data: (Start at label_start) and set "persistent.var_resetdata = 1"

Code: Select all

label start:
    if persistent.var_resetdata = 1:
        $ persistent.var_badendseen = 0
        $ persistent.var_resetdata = 0
    "Some scenes"
    "Time for the choice"

label first_choice:
    "Wut wut, what do I do now?"
    menu:
        "Plead with her":
            if persistent.var_badendseen = 1
                "You will get the good route anyway"
                jump good_scenes
            else:
                "Go to the bad end"
                jump bad_scenes
        "Convince her":
            "Continue game"
            jump good_scenes

label bad_scenes:
    "You will die"
    $ persistent.var_badendseen = 1
    "DEAD"
    return # THIS WILL RETURN TO THE MAIN MENU. IT WILL FORGET NORMAL VARIABLES (And that's why you use persistent variables)

label good_scenes:
    "Continue game from here"
That is how I would do it. You can either use persistent data (and reset the data with a special button) or you can restart without using the main menu.

If you don't want the menu to pop up AT ALL when you already seen the bad end, do something like this:

Code: Select all

label first_choice:
    "Wut wut, what do I do now?"
    if not var_badendseen = 1
        menu:
            "Plead with her":
                "You're screwed"
                jump bad_scenes
            "Convince her":
                "Continue game"
                jump good_scenes
    else:
        jump good_scenes
The last possibility is to always go back to the title screen, and use persistent variables, but also reset the persistent variables to "0" or "false" at the start NO MATTER WHAT. This way, you can only get the "there is no bad ending" option if you use LOAD GAME and no other way. I would advice against this, since it's very counter-intuitive for many players. THEY need to know when data is being reset too.

Akuni
Regular
Posts: 40
Joined: Wed Dec 07, 2011 7:06 pm
Location: REDACTED
Contact:

Re: Resetting Game Progress with a new playthrough

#5 Post by Akuni »

theCodeCat wrote:If the player starts their second playthrough from the main menu, then those state variables should automatically be reset.
Have you tried starting a second playthrough an seeing what happens?

Yea man :(
I started a new game from the main menu, and I never saved on any of the playthroughs but the game still remembers my choices and the variables I set up still count so I don't see the bad end route on my New Game Playthrough, unless I go in and delete the save folder <-- which I guess makes sense? But not with the loop thing I set up :c

xela wrote: I believe that you're thinking about this problem all wrong, you don't "reset" all variables to have something new happen or not happen on the next play through, you do the exact opposite, you change a variable and use it as a "flag" to control "gameflow". All other variables you'll have to reset, you can either do that by creating a label where you define all variables like:

Code: Select all

label my_default_vars:
    python:
        vat1 = False
        var2 = 2141
        var3 = "Apples"
    return
and call it when you require a reset but declare your "gameflow" variables somewhere prior to this call else or restart the game and use persistent data.

Difference between the two is that your variant (no new game) will make sure that if a New Game is trully started, people will see the bad choices again. Persistent data will make sure that the bad choice is never seen again, until the persistent is cleared, even if a new game is started properly.

Ok I understand the gist of what you're saying.
So I would have to put in the script.rpy a new label with the variables I want to 'reset' when they start a new game, and put another label above that with the variables that are required for the game to flow?
And I'm guessing they all can't be the same variables as well, meaning they'd need different names?

User avatar
xela
Lemma-Class Veteran
Posts: 2481
Joined: Sun Sep 18, 2011 10:13 am
Contact:

Re: Resetting Game Progress with a new playthrough

#6 Post by xela »

I don't follow...

1) The variables are "not reset" if you start a new game, they will be bound (created anew). It's "kinda" the same thing?
2) Variables that "survive" starting of a new game are called persistent variables and are bound to a persistent object. They will survive game restart.
3) You "reset" only when you are not starting a new game but trying to "throw" the player back to some point within the same game play.

You need to decide what you want to do and how you want to go around doing it.
Like what we're doing? Support us at:
Image

Akuni
Regular
Posts: 40
Joined: Wed Dec 07, 2011 7:06 pm
Location: REDACTED
Contact:

Re: Resetting Game Progress with a new playthrough

#7 Post by Akuni »

sunwave wrote:Yes, at mentioned above, you will just have to call a label that resets all your persistent variables if you want to reset your game data. Do them manually, one by one. It gives the best result since you can reset them to their "default/beginning" states instead of just clearing them completely. This way, the game will always remember you did the bad end, until you reset the game data with a special button or something.
Like at the starting menu? There would be a different button they'd click to start the game?
sunwave wrote:Note: I get from your code that you want the menu choice to still pop up, but lead to the correct ending anyway, right? At least, that's what you did.
Yes and No. What I was trying to do was force the player into a corner where they would automatically pick the 'right choice.' So when they play the game for the first time they see the options A & B, when they pick A - it's a dead end play, they lose and they're returned to the same choice again to pick. If they try to pick A a second time then they would get stuck in a loop until they pick the other option.

I think I'm gonna have to read up more on persistent variables because I'm doing something very off :c I tried inputting some of that code from the second block but it keeps bringing up errors.

Post Reply

Who is online

Users browsing this forum: Yahoo [Bot]