Is it safe to add new config variables?

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
EveningDove
Newbie
Posts: 5
Joined: Thu Jun 07, 2018 2:20 pm
Contact:

Is it safe to add new config variables?

#1 Post by EveningDove » Thu Jul 12, 2018 3:54 pm

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!!

User avatar
trooper6
Lemma-Class Veteran
Posts: 3386
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?

#2 Post by trooper6 » Thu Jul 12, 2018 4:45 pm

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:

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

EveningDove
Newbie
Posts: 5
Joined: Thu Jun 07, 2018 2:20 pm
Contact:

Re: Is it safe to add new config variables?

#3 Post by EveningDove » Thu Jul 12, 2018 5:04 pm

Thank you so much!! I had no idea define did that, thanks!

As a quick follow-up question, is there any difference between doing:

Code: Select all

define days = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]
and

Code: Select all

init:
    define days = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]

kivik
Miko-Class Veteran
Posts: 784
Joined: Fri Jun 24, 2016 5:58 pm
Contact:

Re: Is it safe to add new config variables?

#4 Post by kivik » Thu Jul 12, 2018 7:09 pm

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

User avatar
trooper6
Lemma-Class Veteran
Posts: 3386
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?

#5 Post by trooper6 » Thu Jul 12, 2018 9:09 pm

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

Post Reply

Who is online

Users browsing this forum: Imperf3kt