Q on variables and save/load

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
Posts: 1
Joined: Sun May 08, 2011 10:48 am

Q on variables and save/load

#1 Post by Fuscian_Fox » Sun May 08, 2011 11:25 am

When someone loads my game, I want it to also load the same variables that were originally saved, not to continue using variable values gained from progression in the game.

For example. Let's say I have the variable vcheck = "false". Right now if I save a gameplay and then continue on to points in the game that set, vcheck = "true". then when I load back to that save, vcheck is still equal to "true" instead of "false". I want the game to load back to when vcheck = "false", how do I do this?

Sorry if this is a stupid question. I'm still pretty new to the language and I had no idea how to search for this kind of question.
I already read up on persistent variables and such, but that seems to be the opposite of what I'm looking for.

User avatar
Lemma-Class Veteran
Posts: 2501
Joined: Fri Dec 11, 2009 5:25 pm

Re: Q on variables and save/load

#2 Post by Alex » Mon May 09, 2011 5:29 am

quite strange behaviour, 'cause it must use "vcheck"'s value that was saved before. So, are you shure that you use proper save, or saved value was actually "True"?
Random thoughts:
1. When you make changes to your code you should start your game from very beginning and make new saves - old saves uses old (unchanged) code.
2. How do you change your variable?

Code: Select all

label start:
    $ my_var = False
    "If you save here, the value would be 'False'."
    scene black
    $ renpy.pause (3.0)  # the value would be 'False'
    $ my_var = True
    "If you save here, the value would be 'True'."
Also, Ren'py is unable to save game state in the middle of python block. Or you can met some troubles when change values through the functions or use "call" function.
It would be much easier to find the problem if you post your code.

Post Reply

Who is online

Users browsing this forum: Google [Bot]