Setting default variables on loading an old save?

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
User avatar
Zet
Regular
Posts: 26
Joined: Wed Feb 13, 2013 12:48 am
Completed: Max's Big Bust
Organization: Lached Up Games
Contact:

Setting default variables on loading an old save?

#1 Post by Zet »

Hey everyone.

I've currently got a game on Early Access on Steam, and I'm having a bit of trouble in regards to rolling out new releases of the game. People are able to use their old save games no problem at first, but as soon as they come across a new variable that hasn't been defined for them as it's been added in a new update, the game crashes.

Is there any way to set a default value for all of these variables, so that if they aren't defined the game either assumes their value is 0 or 'true' so that the game can continue? I've already got some workarounds in mind but it would be good if there was an easy fix for this.

Cheers :)
Lach
Check out Max's Big Bust on Steam - http://store.steampowered.com/app/416360

Onishion
Veteran
Posts: 295
Joined: Mon Apr 20, 2015 10:36 am
Contact:

Re: Setting default variables on loading an old save?

#2 Post by Onishion »

Someone can correct me if I'm wrong, but I believe if you use the code:

default varaiblename = intialvalue

Then if that variable does not already have a value then it will take on that initial value and should work for your purposes. It's a fairly recent addition to the system, so it isn't as well documented as some of the other methods. You can apparently even put these lines wherever you like in the code, so like right next to a relevant section, and they still go into effect at launch.

User avatar
Zet
Regular
Posts: 26
Joined: Wed Feb 13, 2013 12:48 am
Completed: Max's Big Bust
Organization: Lached Up Games
Contact:

Re: Setting default variables on loading an old save?

#3 Post by Zet »

Thanks for the info Onishion, that's super helpful!

Cheers :)
Lachlan
Check out Max's Big Bust on Steam - http://store.steampowered.com/app/416360

Post Reply

Who is online

Users browsing this forum: No registered users