Page 1 of 1
Is it safe to add new config variables?
Posted: Thu Jul 12, 2018 3:54 pm
by EveningDove
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!!
Re: Is it safe to add new config variables?
Posted: Thu Jul 12, 2018 4:45 pm
by trooper6
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
Re: Is it safe to add new config variables?
Posted: Thu Jul 12, 2018 5:04 pm
by EveningDove
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"]
Re: Is it safe to add new config variables?
Posted: Thu Jul 12, 2018 7:09 pm
by kivik
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
Re: Is it safe to add new config variables?
Posted: Thu Jul 12, 2018 9:09 pm
by trooper6
You don't need the init.