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?
Help with the if statement?
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: 19
- Joined: Mon Jul 15, 2013 4:55 pm
- Contact:
- Googaboga
- Eileen-Class Veteran
- Posts: 1395
- Joined: Wed Dec 12, 2012 1:37 pm
- Completed: https://gbpatch.itch.io/
- Projects: Floret Bond, XOXO Blood Droplets, Our Life
- Organization: GB Patch Games
- Tumblr: gb-patch
- itch: gbpatch
- Contact:
Re: Help with the if statement?
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.
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.
In-Progress:
Floret Bond, XOXO Blood Droplets, Our Life
Released:
A Foretold Affair, My Magical Divorce Bureau, XOXO Droplets, Lake of Voices
Floret Bond, XOXO Blood Droplets, Our Life
Released:
A Foretold Affair, My Magical Divorce Bureau, XOXO Droplets, Lake of Voices
-
- Newbie
- Posts: 19
- Joined: Mon Jul 15, 2013 4:55 pm
- Contact:
Re: Help with the if statement?
Omg I get it now! Thank you so much, it worked!!!
Who is online
Users browsing this forum: snotwurm