IF commands
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.
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.
-
- Newbie
- Posts: 3
- Joined: Mon Apr 16, 2007 4:12 am
- Contact:
IF commands
Hi everyone. I only downloaded the software yesterday but I'm intrigued!! hehe. I was wondering: is it possible to have a value (eg: 'strength') and then have the game refrence that value and branch a conversation accordingly? Just as an eample: if strength = 1 then "the bolder dosent move", if strength > 1 "you move the boulder". I have searched the helpfiles and I cant seem to get this to work. Can anyone help?
Yes, it's possible. You can store value this way (strength - the name of the value is called variable):
And if you want to compare the variable to some value you do it:
Note that for assigning value to variable ONE equal sign is used but for testing if variable is equal to some value TWO equal signs are used.
You can find out more here: http://renpy.org/
Code: Select all
$ strength = 1
Code: Select all
if strength < 10:
"You are weak."
if strength == 10:
"You are strong"
if strength > 10:
"You are very strong"
Note that for assigning value to variable ONE equal sign is used but for testing if variable is equal to some value TWO equal signs are used.
You can find out more here: http://renpy.org/
-
- Veteran
- Posts: 384
- Joined: Thu Jun 01, 2006 12:46 pm
- Projects: Project Nattsu, Take Rena Home
- Contact:
Oh and, if you want to continue the story only if the character is strong enough to move the border and thus for example enter a cave, or something alike, you could do something like...
I don't know if this is the absolutely wisest thing to do since I'm quite much a Ren'Py newbie myself, but at least it works... I think. And then you continue the story in the label "cave":
Code: Select all
if strenght < 10:
"You aren't strong enough to move the boulder."
if strenght == 10:
"Using all of your strenght, you push the boulder aside."
jump cave
if strenght > 10:
"You push the boulder aside with ease."
jump cave
Code: Select all
label cave:
"The cave is very dark and quite scary."
"And then blah blah blah, blah blah blah..."
-
- Newbie
- Posts: 3
- Joined: Mon Apr 16, 2007 4:12 am
- Contact:
I've come across that one lots before. It might be an indentation problem, if you look at the line it mentions in the traceback it will probably look something like this
when it should look like this
Code: Select all
if strength > 1:
jump here
Code: Select all
if strength > 1:
jump here
-
- Miko-Class Veteran
- Posts: 649
- Joined: Fri Dec 16, 2005 5:21 pm
- Completed: Fading Hearts, Infinite Game Works
- Projects: Don't Save the World
- Organization: Sakura River
- Location: Canada
- Contact:
-
- Newbie
- Posts: 3
- Joined: Mon Apr 16, 2007 4:12 am
- Contact:
Who is online
Users browsing this forum: Google [Bot], voluorem