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.
-
dm251
- Newbie
- Posts: 18
- Joined: Thu Nov 18, 2010 8:54 pm
- Location: Hiding in your Closet
-
Contact:
#1
Post
by dm251 » Fri Nov 19, 2010 9:57 am
I've been trying on doing things such as this one...
like setting a variable for counting.
e.g
later, when choices are made from a menu, the count adds another point,
like
until such that on the last part using an if statement to determine if the player will get a good or bad ending...
I' tried practicing that very idea but I'm a bit unfamiliar with Ren'Py.
Would be great if someone can tell me on how to do it .

-
Incendium
- Regular
- Posts: 25
- Joined: Wed Dec 09, 2009 12:57 am
-
Contact:
#2
Post
by Incendium » Fri Nov 19, 2010 10:59 am
The Ren'Py language doesn't support setting variables (except in special cases), but Python does. You can turn a Ren'Py statement into a Python statement by prefixing it with "$" or putting it in a "python:" block.
Code: Select all
"Greetings, user!"
menu:
"Where do you want to go?"
"Here":
$ count = 1
"There":
$ count = 2
"Your count is currently %(count)d."
python:
count += 1
"Your count is now %(count)d."
-
dm251
- Newbie
- Posts: 18
- Joined: Thu Nov 18, 2010 8:54 pm
- Location: Hiding in your Closet
-
Contact:
#3
Post
by dm251 » Sat Nov 20, 2010 2:57 am
Oooohh... So thats how it works.. Thanks dude
but if I used the ifs? How would I do it that way?
-
broken_angel
- Veteran
- Posts: 322
- Joined: Sun Oct 03, 2010 11:49 pm
- Completed: Memoirs of an Angel (2010)
- Projects: Memoirs of an Angel (Remake); W.I.S.H
- Location: United States
-
Contact:
#4
Post
by broken_angel » Sat Nov 20, 2010 3:11 am
As in...
Code: Select all
if count == 4:
"Stuff happens here."
Yes, that works. C:
You can also do "count < 4", "count > 4", or combine statements like "count > 1 and count < 4"
-
dm251
- Newbie
- Posts: 18
- Joined: Thu Nov 18, 2010 8:54 pm
- Location: Hiding in your Closet
-
Contact:
#5
Post
by dm251 » Sat Nov 20, 2010 4:35 am
Whoah. Thanks again

I'll ask another question whenever I'm in trouble again then

-
dm251
- Newbie
- Posts: 18
- Joined: Thu Nov 18, 2010 8:54 pm
- Location: Hiding in your Closet
-
Contact:
#6
Post
by dm251 » Tue Nov 23, 2010 9:14 am
Err.. I had a trouble again.
I did it like this
Code: Select all
"So. I walked to the rooftop."
$ Sneak = True
if Sneak = True
"Mah, Its not bad to stay here for a while...{p}The wind is so refreshing today huh?"
and when I test it...
It goes
Code: Select all
I'm sorry, but errors were detected in your script. Please correct the
errors listed below, and try again.
On line 182 of C:\renpy-6.11.2\Games\--\---/game/script.rpy: reached end of line when expecting ':'.
if Sneak = True
On line 129 of C:\renpy-6.11.2\--\---/game/script.rpy: invalid syntax
$ Sneak = True
What do I do? I tried what I can but I never fixed this one

-
fortaat
- Regular
- Posts: 183
- Joined: Tue May 18, 2010 1:16 pm
-
Contact:
#7
Post
by fortaat » Tue Nov 23, 2010 9:22 am
Add colon after 'True':
Code: Select all
"So. I walked to the rooftop."
$ Sneak = True
if Sneak = True:
"Mah, Its not bad to stay here for a while...{p}The wind is so refreshing today huh?"
-
Showsni
- Miko-Class Veteran
- Posts: 563
- Joined: Tue Jul 24, 2007 12:58 pm
-
Contact:
#8
Post
by Showsni » Tue Nov 23, 2010 9:28 am
Grr. Google Chrome ate my post.
Er hem. Like it says, you're missing a colon; for checking things with if, you need to end in a colon and indent the next line. You also need to use double equals sign for checking things. So,
Code: Select all
if Sneak == True:
"Mah, Its not bad to stay here for a while...{p}The wind is so refreshing today huh?"
Note that for True and False you can just leave out the equals signs if you want and do:
Code: Select all
if Sneak:
"Mah, Its not bad to stay here for a while...{p}The wind is so refreshing today huh?"
See here for more help:
http://www.renpy.org/wiki/renpy/doc/tut ... er_Choices
-
dm251
- Newbie
- Posts: 18
- Joined: Thu Nov 18, 2010 8:54 pm
- Location: Hiding in your Closet
-
Contact:
#9
Post
by dm251 » Tue Nov 23, 2010 10:41 am
I see...
Yay it works.
Thanks a bunch Showsni and Fortaat