Page 1 of 1

Help with the if statement?

Posted: Sun Apr 13, 2014 12:08 am
by Purpleryuk
So I am attempting to make a game but I really wanna know how to use the if statement so I can make it easier on myself. I've read over the help and tutorials on the ren'py wiki but it never works. This is the menu I want to do using the if statement,
menu:
"\"The Dresser\"":
$ Sword = True
jump dresser
"\"The Bag\"":
$ Bow_Arrow = True
jump bag
"\"Under the Bed\"":
$ Tomahawk = True
jump bed
and then when I do this,
menu:
"Use which?"
"The Sword" if Sword == True:
"I run towards him slamming my sword against him"
$ Selo_Health -= 2
"Suddenly, he punches my gut before I can dodge him"
$ Heather_Health -= 1
jump sa1
"The Bow and Arrows" if Bow_Arrow == True:
"I pulled back an arrow but miss and hit him in the arm instead"
$ Selo_Health -= 2
"He tries to run towards me to hit me but I quickely move away"
jump sa1
"The Tomahawk" if Tomahawk == True:
"I run as fast as I can and slam him with the tomahawk"
$ Selo_Health -= 5
"But then he smacks me in the side, catching me off guard. While I'm still down he kicks me"
$ Heather_Health -= 3
jump sa1
it tells me that Sword, Bow_Arrow, and Tomahawk aren't defined but I don't know what that means. I thought I defined them already but I guess I didn't so how do I do that?

Re: Help with the if statement?

Posted: Sun Apr 13, 2014 12:19 am
by Googaboga
To define something means that you say it's there before you change it or do something with it. It can't start out as 'True' so the first time you mention it it needs to be 'False'. So before you say '$ Sword = True' you need to have '$ Sword = False' somewhere earlier in the code. Once you add that '$ Sword = False' you will have defined it and can then you can change it back and fourth between true and false as much as you want.

I suggest defining all of them immediately after the 'label start'. Just have them as the very first thing. That way you know for sure that they'll be defined in advanced when you go to use them later.

Re: Help with the if statement?

Posted: Sun Apr 13, 2014 2:50 am
by Purpleryuk
Omg I get it now! Thank you so much, it worked!!!