Hi, I was wondering if it's possible to make a constant variable that is not intended to change after the game has been initiated (similarly to how final works in Java).
I know the config variables work similarly to this, but I wasn't sure if it's a good idea to make new ones. Also, if it is safe to make new config variables, is there even any meaningful efficiency gain from doing this, or would I just be better off making a bunch of global variables?
Thanks!!
Is it safe to add new config variables?
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.
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.
-
- Newbie
- Posts: 5
- Joined: Thu Jun 07, 2018 2:20 pm
- Contact:
- trooper6
- Lemma-Class Veteran
- Posts: 3712
- Joined: Sat Jul 09, 2011 10:33 pm
- Projects: A Close Shave
- Location: Medford, MA
- Contact:
Re: Is it safe to add new config variables?
If you want to make a variable that won't change after the game is initialized, use define. If you plan on changing the variable, use default.
So for example:
So for example:
Code: Select all
define days = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]
default money = 0
label start():
"Game starts"
"Game over"
return
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
*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
-
- Newbie
- Posts: 5
- Joined: Thu Jun 07, 2018 2:20 pm
- Contact:
Re: Is it safe to add new config variables?
Thank you so much!! I had no idea define did that, thanks!
As a quick follow-up question, is there any difference between doing:
and
As a quick follow-up question, is there any difference between doing:
Code: Select all
define days = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]
Code: Select all
init:
define days = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]
Re: Is it safe to add new config variables?
Technically no difference, but the define keyword is redundant in the second scenario.
See documentation about define here: https://www.renpy.org/doc/html/python.h ... -statement
See documentation about define here: https://www.renpy.org/doc/html/python.h ... -statement
- trooper6
- Lemma-Class Veteran
- Posts: 3712
- Joined: Sat Jul 09, 2011 10:33 pm
- Projects: A Close Shave
- Location: Medford, MA
- Contact:
Re: Is it safe to add new config variables?
You don't need the init.
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
*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
Who is online
Users browsing this forum: Ahrefs [Bot], AWizardWithWords