Home Creators Posts Import Register Favorites Logout

Content

Hello there!

Ok, today, we'll speak a little about the variables in Ren'Py.

But... What is a variable? Thank you for asking!

Basically, a variable is something that have a name and contain a value. In some langage, the variable also got a type, but not in Ren'Py.

VariaName = 0.1  means that the variable with the name VariaName got the value 0.1.

Simple, right? Ok, thank you and see you next time for another class.

What...? You're still here? Ok!

So, in Ren'py, variable are, usually but not always, declare in a file named "variables.rpy". This file is loaded each time you begin a new game or load a save.

It should contain all the variable that will be use in your story scripts.

But how you declare a variable? There is two way to do that :

'default CelesteLovPoints = 0'

and

'define McDefaultName = "Moon"'

default? define? Which one for what?

Default is an instruction only play one time by renpy : when the variable is not yet initialise in your game. Basically, at the beginning, or if you add a new variable during the game or in a new update.

Default give the "default" (Yes!) value of this variable. But you're able to change this value anytime you need it.

Define is an instruction play each time you load/begin a new game. Define stick the value of the variable. You must not change a variable "defined" during the story. It's called a static variable.

But... And we'll see that usually for the definition of the MC :

define mc       = Character("[mcname]")

The variable "mc" is always a Character with name = [mcname]. But... The name here is especially [mcname] and not the value of mcname. So it can change along the story.

Another things specific to define : You can change its value in the variables.rpy file, it will be changed in all the game.

Yeah, it's harder than it seems, right?

Basically, if you need to remember something :

default = first value but you can change it in the story (but not in the variables.rpy file)

define = definitive value, don't change it in the story, only in the define (but also, you can change it's value in the define).

Do you have any questions?

And what would you want to see in the next Dev Tips?

See you all!

MoonLight

Files

Comments

No comments found for this post.