Page 1 of 1
Storing variables and such
Posted: Fri Nov 19, 2010 9:57 am
by dm251
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 .
Re: Storing variables and such
Posted: Fri Nov 19, 2010 10:59 am
by Incendium
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."
Re: Storing variables and such
Posted: Sat Nov 20, 2010 2:57 am
by dm251
Oooohh... So thats how it works.. Thanks dude
but if I used the ifs? How would I do it that way?
Re: Storing variables and such
Posted: Sat Nov 20, 2010 3:11 am
by broken_angel
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"
Re: Storing variables and such
Posted: Sat Nov 20, 2010 4:35 am
by dm251
Whoah. Thanks again
I'll ask another question whenever I'm in trouble again then
Re: Storing variables and such
Posted: Tue Nov 23, 2010 9:14 am
by dm251
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
Re: Storing variables and such
Posted: Tue Nov 23, 2010 9:22 am
by fortaat
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?"
Re: Storing variables and such
Posted: Tue Nov 23, 2010 9:28 am
by Showsni
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
Re: Storing variables and such
Posted: Tue Nov 23, 2010 10:41 am
by dm251
I see...
Yay it works.
Thanks a bunch Showsni and Fortaat