Hi.
I read something about this, but I don't get it.
In my game, I declare all variables right after the label start: obviously, this causes the inconvenience that every time I add a new variable, I need to start the game again since the old saves will be broken.
From what I read, I can declare these variables in the script before the "label start" using the "default". However, I read some comments saying that declaring all variables before the game starts is not a good practice (???).
My question is simple: can I declare all variables using Default at the beginning of the script? Can this cause some problem with rollback or stuff like that?
Use "default" to declare variables before label "start" ?
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.
- wyverngem
- Miko-Class Veteran
- Posts: 615
- Joined: Mon Oct 03, 2011 7:27 pm
- Completed: Simple as Snow, Lady Luck's Due,
- Projects: Aether Skies, Of the Waterfall
- Tumblr: casting-dreams
- itch: castingdreams
- Location: USA
- Contact:
Re: Use "default" to declare variables before label "start" ?
You can even put all default variables in it's own rpy. It won't hurt it. You need to define them before you use them, so default is fine. You could also put them in an init block before the start label like this.
Code: Select all
default name = "Reina"
init:
$ MeetSarah = False
$ kissedSarah = False
label start:
"My name is [name]. Who are you?"
if name == "Barbara":
"You won't see this option becuase her default is Reina and I didn't write before this line to change her name with a variable."
else:
"Umm...that's not the name of the list. She's [name]. Do you want to be Barbara?"
menu:
"Yes":
$ name = "Barbara"
jump start
"No":
"You're loss."
return- trooper6
- Lemma-Class Veteran
- Posts: 3712
- Joined: Sat Jul 09, 2011 10:33 pm
- Projects: A Close Shave
- Location: Medford, MA
- Contact:
Re: Use "default" to declare variables before label "start" ?
Current best practices is to declare your variables outside of any block using default. This will ensure you will be fine with saving and rollback.
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
- IrinaLazareva
- Veteran
- Posts: 399
- Joined: Wed Jun 08, 2016 1:49 pm
- Projects: Legacy
- Organization: SunShI
- Location: St.Petersburg, Russia
- Contact:
Who is online
Users browsing this forum: Google [Bot]
