How do I define my variables and more specifically 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
DictatorKitten
Newbie
Posts: 3
Joined: Fri Jan 29, 2016 1:07 pm
Deviantart: KittenRazorBlades
Skype: itickleurbutts
Contact:

How do I define my variables and more specifically where?

#1 Post by DictatorKitten »

I keep reading tutorials on how to define variables, but I haven't quite familiarized myself with ren'py enough to know where to define the variables( do I define them like I define characters or do I define them in a python block?), how to set variables, and how to write if statements. I basically know how to begin a python block, and that is the limit of my knowledge. I think I managed to set user input well, but I'd really appreciate help.

Futhermore, if it helps at all, I need number variables for an affection meter!

User avatar
Iylae
Regular
Posts: 73
Joined: Sat Jan 09, 2016 6:57 am
Location: Cornwall, UK
Contact:

Re: How do I define my variables and more specifically where

#2 Post by Iylae »

There's enough questions in here to direct you to the documentation: http://www.renpy.org/doc/html/

Any line that begins with a $ or is in a python: block is python code. Everything not in this is RenPy. Variables can be defined when you require them. I suggest you work your way through the examples in the "Getting Started" example of the documentation.
Image
  If we are what we repeatedly do, then good coding is not an act, but a habit

User avatar
DictatorKitten
Newbie
Posts: 3
Joined: Fri Jan 29, 2016 1:07 pm
Deviantart: KittenRazorBlades
Skype: itickleurbutts
Contact:

Re: How do I define my variables and more specifically where

#3 Post by DictatorKitten »

Iylae wrote:There's enough questions in here to direct you to the documentation: http://www.renpy.org/doc/html/

Any line that begins with a $ or is in a python: block is python code. Everything not in this is RenPy. Variables can be defined when you require them. I suggest you work your way through the examples in the "Getting Started" example of the documentation.
I read the Ren'py documentation on variables already, that's why I came here. I didn't understand it :3/

User avatar
xela
Lemma-Class Veteran
Posts: 2481
Joined: Sun Sep 18, 2011 10:13 am
Contact:

Re: How do I define my variables and more specifically where

#4 Post by xela »

Really? Docs are very clear on the variables definitions. Best way is simply to:

Code: Select all

default my_var = 0
default my_var_2 = {}
default my_var_3 = False
without any labels, screens, python or any other blocks, but you should be able to put it on the init block safely if you want all of them to be grouped together (it's convenient in JEdit for example, which I use).

Code: Select all

label start:
    $ my_var = 0
    python:
        my_var_2 = {}
        my_var_3 = False
will work just as well. Do not ever declare variables in the anything init without default or older define statements, you'll regret that later, use one of the ways above.
Like what we're doing? Support us at:
Image

User avatar
DictatorKitten
Newbie
Posts: 3
Joined: Fri Jan 29, 2016 1:07 pm
Deviantart: KittenRazorBlades
Skype: itickleurbutts
Contact:

Re: How do I define my variables and more specifically where

#5 Post by DictatorKitten »

xela wrote:Really? Docs are very clear on the variables definitions. Best way is simply to:

Code: Select all

default my_var = 0
default my_var_2 = {}
default my_var_3 = False
without any labels, screens, python or any other blocks, but you should be able to put it on the init block safely if you want all of them to be grouped together (it's convenient in JEdit for example, which I use).

Code: Select all

label start:
    $ my_var = 0
    python:
        my_var_2 = {}
        my_var_3 = False
will work just as well. Do not ever declare variables in the anything init without default or older define statements, you'll regret that later, use one of the ways above.
Oh! Okay! I apologize, I'm not incredibly good with tutorials(for whatever reason), but yeah, this answers what I needed to know uwu

Post Reply

Who is online

Users browsing this forum: Sugar_and_rice