How to make game remember that you finished it?

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
ScoutHiro
Newbie
Posts: 3
Joined: Mon Jul 04, 2016 9:15 am
Contact:

How to make game remember that you finished it?

#1 Post by ScoutHiro » Fri Jul 15, 2016 8:03 am

I'm making a test file, and I have a menu with an item that will only show up if "finishedgame == True". The finishedgame is set as True just before the Return, but renpy is angry at me because it does not exists at the beginning, and if I write it without any value it says the same, "NameError: name 'finishedgame' is not defined".
Thing is, if I give him a value, it will simply overwrite the last one...
I tried using this guide https://www.renpy.org/wiki/renpy/doc/tu ... er_Choices but I don't understand how it will remember the "park_date_done" for example.
And I guess I will also need it for unlockable routes. x_x

User avatar
chocoberrie
Veteran
Posts: 254
Joined: Wed Jun 19, 2013 10:34 pm
Projects: Marshmallow Days
Contact:

Re: How to make game remember that you finished it?

#2 Post by chocoberrie » Fri Jul 15, 2016 11:14 am

Are you asking about a single menu item being remembered, or the whole game being finished...? :?

I'll try to explain what's in the documentation, maybe that'll help.

Code: Select all

b "So, where would you like to go, Mary?"

menu:
     "I'd like to go to the park!":
          jump park_date
     "I'd like to go to the cafe!":
          jump cafe_date
     "Can we go tortoise racing?" if gift == "tortoise":
          jump tortoise_racing
In the code above, the third menu choice about tortoise racing only shows up if in the previous part of the script, Mary is given the tortoise as a gift. This is written using if gift == "tortoise" with "tortoise" in quotes, referencing this previous part of the script:

Code: Select all

menu:
    "Buy her an Iguana":
        $ gift = "iguana"
        b "I'll take an iguana, my good man!"
    "Buy her a Corn Snake":
        $ gift = "corn snake"
        b "I'll take a Corn Snake, my good man!"
    "Buy her a tortoise":
        $ gift = "tortoise"
        b "Give me your slowest tortoise, please!"
In the above code, $ gift = "tortoise", so if the player clicks that option, Ren'Py remembers it, and can reference this choice to make the option "Can we go tortoise racing?" show up in the menu later. The tortoise racing option only appears in the menu if the statement if gift == "tortoise" is true (in other words, this means that the player must have clicked the option associated with $ gift = "tortoise").

If you want to make a specific menu option only appear once the player reaches the end of the game - based on the example code above - I think you would need to have something like:

Code: Select all

$ finishedgame = "finished"
and

Code: Select all

if finishedgame == "finished"
in your script.

$ finishedgame = "finished" (with only one equal sign) defines the variable so that Ren'Py remembers it, and if finishedgame == "finished" (with two equal signs) is the point at which the variable is supposed to be tested.

So I think that if finishedgame == "finished" is supposed to be written with the menu choice that you want to show, like this:

Code: Select all

menu:
     "Choice 1":
          jump choice_1
     "Choice 2":
          jump choice_2
     "Hidden choice" if finishedgame == "finished":
          jump hidden_choice
Then you would use the labels associated with the jump statements, as usual:

Code: Select all

label choice_1:
    # code here

label choice_2:
    # code here

label hidden_choice:
    # code here
I'm not sure where $ finishedgame = "finished" would go... Based on the documentation, it should go in the script before if finishedgame == "finished" but I don't know where, exactly.

Any ideas, anyone? :)

User avatar
trooper6
Lemma-Class Veteran
Posts: 3712
Joined: Sat Jul 09, 2011 10:33 pm
Projects: A Close Shave
Location: Medford, MA
Contact:

Re: How to make game remember that you finished it?

#3 Post by trooper6 » Fri Jul 15, 2016 1:08 pm

Regular variables are only exist within the game. If you want variables that carry over between games, you want the use persistent variables. I'm on my phone so I can't post a link, but just search for persistent in the documentation and the questions thread.
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)
Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978

User avatar
chocoberrie
Veteran
Posts: 254
Joined: Wed Jun 19, 2013 10:34 pm
Projects: Marshmallow Days
Contact:

Re: How to make game remember that you finished it?

#4 Post by chocoberrie » Fri Jul 15, 2016 1:27 pm

trooper6 wrote:Regular variables are only exist within the game. If you want variables that carry over between games, you want the use persistent variables. I'm on my phone so I can't post a link, but just search for persistent in the documentation and the questions thread.
Ah, this is true! Good point, trooper6! Here is the documentation about persistent data.

Here are some posts in the forums about implementing persistent data:

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

Re: How to make game remember that you finished it?

#5 Post by sunwave » Sun Jul 17, 2016 12:52 pm

I think he's asking a much simpler question:

Code: Select all

label start:
    "sometext"
    menu:
        "option A":
            "Whatever"
        "option B":
            "Whoopsiedoodle"
        "special option" if finishedgame == True:
            "Blahdieblah"

label allscenes:
    "Game stuff"
    $ finishedgame = True
This will give an error because at thes tart, the variable "finishedgame" doesn't exit yet. Also, yes, I would make it a persistent variable on top of that.
Basically, when you're checking a variable value, it must have a value of some kind. You can use "None" to check if it hasn't got anything yet. So:

Code: Select all

label start:

    if persistent.finishedgame == "None":               #This will only work for persistent variables, if I'm correct.
        $ persistent.finishedgame = False

    "sometext"
    menu:
        "option A":
            "Whatever"
        "option B":
            "Whoopsiedoodle"
        "special option" if persistent.finishedgame == True:
            "Blahdieblah"

label allscenes:
    "Game stuff"
    $ persistent.finishedgame = True

Post Reply

Who is online

Users browsing this forum: _ticlock_