Possibly stupid Q: Variables must be defined where?

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
User avatar
Sslaxx
Regular
Posts: 52
Joined: Thu Jul 18, 2013 7:35 pm
Deviantart: sslaxx
Github: Sslaxx
Skype: Sslaxx
Location: Malvern, UK
Discord: Sslaxx#0159
Contact:

Possibly stupid Q: Variables must be defined where?

#1 Post by Sslaxx »

I can't find the original thread now (go me), but I recall it saying something along the lines that if a variable is not defined in a label, it isn't saved (as part of a save game) if its value is changed somewhere else later on.

Is this right, or have I got the wrong end of the stick here? Thanks.
Stuart "Sslaxx" Moore.

SundownKid
Lemma-Class Veteran
Posts: 2299
Joined: Mon Feb 06, 2012 9:50 pm
Completed: Icebound, Selenon Rising Ep. 1-2
Projects: Selenon Rising Ep. 3-4
Organization: Fastermind Games
Deviantart: sundownkid
Location: NYC
Contact:

Re: Possibly stupid Q: Variables must be defined where?

#2 Post by SundownKid »

Variables need to be defined in the "init" block. For example:

Code: Select all

init:
   $cheetoseaten = 0

User avatar
Sslaxx
Regular
Posts: 52
Joined: Thu Jul 18, 2013 7:35 pm
Deviantart: sslaxx
Github: Sslaxx
Skype: Sslaxx
Location: Malvern, UK
Discord: Sslaxx#0159
Contact:

Re: Possibly stupid Q: Variables must be defined where?

#3 Post by Sslaxx »

Hmmm. So, then, like this?

Code: Select all

init:
 define EndType = "END"
Shall keep this in mind.
Stuart "Sslaxx" Moore.

SundownKid
Lemma-Class Veteran
Posts: 2299
Joined: Mon Feb 06, 2012 9:50 pm
Completed: Icebound, Selenon Rising Ep. 1-2
Projects: Selenon Rising Ep. 3-4
Organization: Fastermind Games
Deviantart: sundownkid
Location: NYC
Contact:

Re: Possibly stupid Q: Variables must be defined where?

#4 Post by SundownKid »

Define might work too, but you probably don't need the "init" with that one, it's just stand alone. Having an init block is the way most people do it, though.

User avatar
xavimat
Eileen-Class Veteran
Posts: 1461
Joined: Sat Feb 25, 2012 8:45 pm
Completed: Yeshua, Jesus Life, Cops&Robbers
Projects: Fear&Love
Organization: Pilgrim Creations
Github: xavi-mat
itch: pilgrimcreations
Location: Spain
Discord: xavimat
Contact:

Re: Possibly stupid Q: Variables must be defined where?

#5 Post by xavimat »

You can define variables also in the labels. Make sure to define your variables before they are used.
The save function must save the current value of your variables (I presume).
Comunidad Ren'Py en español: ¡Únete a nuestro Discord!
Rhaier Kingdom A Ren'Py Multiplayer Adventure Visual Novel.
Cops&Robbers A two-player experiment | Fear&Love Why can't we say I love you?
Honest Critique (Avatar made with Chibi Maker by ~gen8)

Post Reply

Who is online

Users browsing this forum: barsunduk