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.
-
Shiron
- Newbie
- Posts: 18
- Joined: Fri Sep 28, 2018 8:10 am
-
Contact:
#1
Post
by Shiron » Mon Apr 13, 2020 11:15 am
Hi,
please don’t think I’m troll just for asking this, but I thought I’ve solved it already.
For more than a year I’m occasionally working on a game, which is using A LOT of variables. I remeber reading this tutorial at the beginning of the scripting...
https://www.renpy.org/wiki/renpy/doc/tu ... er_Choices
... and I kind of got the idea, that declaring variables like this...
... would work after save.
Apparently not.
(Well, it does work, but if I save it, quit the window and open it again, the values aren’t there.)
I also kind of remeber that it was asked somewhere before, but I can’t really find it. How can I save the variables so they can be loaded again?
Thank you
Last edited by
Shiron on Wed Apr 15, 2020 12:47 pm, edited 1 time in total.
-
Alex
- Lemma-Class Veteran
- Posts: 2981
- Joined: Fri Dec 11, 2009 5:25 pm
-
Contact:
#2
Post
by Alex » Mon Apr 13, 2020 2:44 pm
-
trooper6
- Lemma-Class Veteran
- Posts: 3712
- Joined: Sat Jul 09, 2011 10:33 pm
- Projects: A Close Shave
- Location: Medford, MA
-
Contact:
#3
Post
by trooper6 » Mon Apr 13, 2020 3:14 pm
May I ask why your variable is named set.fantasy? Do you have a object named set that has a variable named fantasy? Set is a reserved name, so you shouldn't be naming anything set. so I have a some larger naming convention questions here.
But anyway, the page you were looking at is outdated and you should be looking at the current documentation rather than the old wiki.
So, variables that you plan on changing should be declared with default, variables that you don't ever plan on changing should be declared with define.
So...
Code: Select all
default s_fantasy = False
define days = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]
label start:
"Whatever the game is happening."
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
-
Shiron
- Newbie
- Posts: 18
- Joined: Fri Sep 28, 2018 8:10 am
-
Contact:
#4
Post
by Shiron » Mon Apr 13, 2020 5:47 pm
So if I understand it correctly, if I rename all "set.xxxx" variables to "set_xxxx" it should work?
I can’t really use that "define" command, because all the variables are distributed through the script (they’re part of quite extensive interactive settings).
-
trooper6
- Lemma-Class Veteran
- Posts: 3712
- Joined: Sat Jul 09, 2011 10:33 pm
- Projects: A Close Shave
- Location: Medford, MA
-
Contact:
#5
Post
by trooper6 » Mon Apr 13, 2020 6:10 pm
All the variables that you want to participate in saving, loading, and rollback must be declared using the "default" command outside of the script. Declaring them within the script is not going to have those variables saved. You change the variables in the script, you declare them outside of the script using default (or define if the variable will never be changed, ever--when in doubt, use default). So you are going to have to add default declarations to your project. You don't have to get rid of all the stuff you've got going on in your script, but you have to add the defaults.
Also, don't use periods for your variables just to separate words, because periods have a specific meaning in python. If you want to separate words use an underscore. So "room_morning" or "points_love" -- not "room.morning" or "points.love" You use the period when you've created a object that has its own variables and methods and you want to access the variables and methods of the object.
And remember not to use any reserved words for your variables, here is the list of reserved names:
https://www.renpy.org/doc/html/reserved.html
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
-
Shiron
- Newbie
- Posts: 18
- Joined: Fri Sep 28, 2018 8:10 am
-
Contact:
#6
Post
by Shiron » Tue Apr 14, 2020 4:48 am
I quess I’ve got the idea.
But just for the future facilitation, can I declare all the used variables of the game in one file, while the script and functions in different files? Do I have to give it the lowest init offset?
-
trooper6
- Lemma-Class Veteran
- Posts: 3712
- Joined: Sat Jul 09, 2011 10:33 pm
- Projects: A Close Shave
- Location: Medford, MA
-
Contact:
#7
Post
by trooper6 » Tue Apr 14, 2020 8:57 pm
You can certainly put all those initial declarations in its own file. The functions can be in their own file as well. The only thing to be aware of is that Ren’py reads the files alphabetically, just make sure you name the file with the variable declarations something earlier in the alphabet than the file with the script and the functions.
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
-
Shiron
- Newbie
- Posts: 18
- Joined: Fri Sep 28, 2018 8:10 am
-
Contact:
#8
Post
by Shiron » Wed Apr 15, 2020 12:45 pm
Okay, thank you.
Users browsing this forum: Bing [Bot], Google [Bot]