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.
-
ashewalton
- Newbie
- Posts: 23
- Joined: Thu Jul 22, 2010 5:11 pm
- Location: Niagara, ON
-
Contact:
#1
Post
by ashewalton » Sun Aug 08, 2010 1:41 am
Looking for the correct way to express the statement "IF relationshipBenjamin is 1 AND minutes is ALSO 900"
Code: Select all
"{color=#FF0000}Study with Benjamin{/color}" if minutes is 900 and relationshipBenjamin is 1:
Any help?
Last edited by
ashewalton on Sun Aug 08, 2010 12:31 pm, edited 1 time in total.
-
Incendium
- Regular
- Posts: 25
- Joined: Wed Dec 09, 2009 12:57 am
-
Contact:
#2
Post
by Incendium » Sun Aug 08, 2010 2:13 am
Try this:
Code: Select all
if minutes == 900 and relationshipBenjamin:
"{color=#FF0000}Study with Benjamin{/color}"
-
ashewalton
- Newbie
- Posts: 23
- Joined: Thu Jul 22, 2010 5:11 pm
- Location: Niagara, ON
-
Contact:
#3
Post
by ashewalton » Sun Aug 08, 2010 11:34 am
Unfortunately, that code fails to check the value of the second variable and make sure it's set to 1 (as it can at this point also be set as 0). Also, it might not have been clear, but this needs to reside within a menu statement, which can't accept else/if blocks. Thanks for the help though ^^;;
-
Alex
- Lemma-Class Veteran
- Posts: 2981
- Joined: Fri Dec 11, 2009 5:25 pm
-
Contact:
#4
Post
by Alex » Sun Aug 08, 2010 11:54 am
Just change the condition to "if minutes == 900 and relationshipBenjamin == 1:"
As for menus, you can use it like
Code: Select all
menu:
"Choice 1" if var1 == 1:
"some text"
"Choice 2" if minutes == 900 and relationshipBenjamin == 1:
"another text"
-
Incendium
- Regular
- Posts: 25
- Joined: Wed Dec 09, 2009 12:57 am
-
Contact:
#5
Post
by Incendium » Sun Aug 08, 2010 11:56 am
Checking for "relationshipBenjamin" checks to see if relationshipBenjamin is not False, and 0 == False.
Try this instead:
Code: Select all
"{color=#FF0000}Study with Benjamin{/color}" if minutes == 900 and relationshipBenjamin == 1:
That's what I get for replying with my cell phone right before I go to bed. <.<
-
Aleema
- Lemma-Class Veteran
- Posts: 2677
- Joined: Fri May 23, 2008 2:11 pm
- Organization: happyB
- Tumblr: happybackwards
-
Contact:
#6
Post
by Aleema » Sun Aug 08, 2010 11:57 am
Because you need to set relationshipBenjamin to True or False. That is the equivalent to what you're doing with zero and one. Then you can check "if relationshipBenjamin" to check if it's True or "if not relationshipBenjamin" if it's False. If you MUST do 1's and 0's, then you write it like "if relationshipBenjamin == 1".
Menu code
can accept if statements. Don't be too quick to discount his help, it was entirely accurate if you had a better understanding of the language. For example, this is what you want:
Code: Select all
$ relationshipBenjamin = True
menu:
"Study with Ben" if minutes == 900 and relationshipBenjamin:
jump study
Edit: Reply storm! Wooboy.
-
PyTom
- Ren'Py Creator
- Posts: 15893
- Joined: Mon Feb 02, 2004 10:58 am
- Completed: Moonlight Walks
- Projects: Ren'Py
- IRC Nick: renpytom
- Github: renpytom
- itch: renpytom
- Location: Kings Park, NY
-
Contact:
#7
Post
by PyTom » Sun Aug 08, 2010 12:06 pm
ashewalton wrote:but this needs to reside within a menu statement, which can't accept else/if blocks.
Yes, it can. An if statement can occur in the code that's run after a menu choice is made, and the menu choices themselves also take if clauses to determine if the choice is shown.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
"Silly and fun things are important." - Elon Musk
Software > Drama •
https://www.patreon.com/renpytom
-
ashewalton
- Newbie
- Posts: 23
- Joined: Thu Jul 22, 2010 5:11 pm
- Location: Niagara, ON
-
Contact:
#8
Post
by ashewalton » Sun Aug 08, 2010 12:27 pm
Haha, thank you everyone. I've tried all the code above prior to asking, so it must just be that something's not defined properly, as opposed to me generally sucking with syntax (which is the usual cause of any errors).
[Edit] Actually, I'd been trying to use && instead of and, so problem solved x3
Users browsing this forum: Bing [Bot]