[SOLVED] Trouble with "IF, ELIF, ELSE" Conditions - Error in Syntax

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.
Post Reply
Message
Author
User avatar
cubierocks
Newbie
Posts: 19
Joined: Sat Nov 03, 2012 11:12 am
Projects: An Everyday Love
itch: hollowrosestudios
Contact:

[SOLVED] Trouble with "IF, ELIF, ELSE" Conditions - Error in Syntax

#1 Post by cubierocks » Wed Apr 07, 2021 8:53 am

Hi all!

Right now I'm having difficulty with correctly using the if,elif,else, conditional coding for my game. I've tried referring to tutorials, but I still can't seem to input the code correctly. Attached I have pictures of my error message, the coding it references, and the current coding I have listed.

What I'm trying to do is have a character mention their favorite lazy day food (which the user chooses), and then later in the game, depending on what they chose earlier, the character will wake up to the scent of their selected favorite lazy day food.

I've listed the variables, adjusted the true/false coding for each, but I still get a syntax error. This error is exacerbated if I adjust the colon next to the "elif,else" statements (hence the space between elif and else and the colon) - I'll get an EOF error with that.

How can I code my conditional statement correctly?
Attachments
Screen Shot 2021-04-06 at 8.01.16 PM.png
Screen Shot 2021-04-06 at 7.59.59 PM.png
Screen Shot 2021-04-06 at 7.59.24 PM.png
Screen Shot 2021-04-07 at 8.52.20 AM.png
Screen Shot 2021-04-07 at 8.43.26 AM.png
Screen Shot 2021-04-07 at 8.43.50 AM.png
Screen Shot 2021-04-06 at 8.01.04 PM.png
Last edited by cubierocks on Wed Apr 07, 2021 12:45 pm, edited 1 time in total.

User avatar
Ocelot
Eileen-Class Veteran
Posts: 1883
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: Trouble with "IF, ELIF, ELSE" Conditions - Error in Syntax

#2 Post by Ocelot » Wed Apr 07, 2021 10:08 am

= is for assignment, not for equality. You nee to use == to compare two values. And a second one: you almost never want to write something == True, you just need to write if something:
< < insert Rick Cook quote here > >

rayminator
Miko-Class Veteran
Posts: 754
Joined: Fri Feb 09, 2018 12:05 am
Location: Canada
Contact:

Re: Trouble with "IF, ELIF, ELSE" Conditions - Error in Syntax

#3 Post by rayminator » Wed Apr 07, 2021 10:12 am

with this image here remove label and remove the space and put it above label start: or on it's own file like init.rpy


Image

User avatar
cubierocks
Newbie
Posts: 19
Joined: Sat Nov 03, 2012 11:12 am
Projects: An Everyday Love
itch: hollowrosestudios
Contact:

Re: Trouble with "IF, ELIF, ELSE" Conditions - Error in Syntax

#4 Post by cubierocks » Wed Apr 07, 2021 11:27 am

I changed the placement of the variables, however, I'm still receiving the same message.
Attachments
Screen Shot 2021-04-07 at 11.26.35 AM.png
Screen Shot 2021-04-07 at 11.26.10 AM.png

User avatar
Alex
Lemma-Class Veteran
Posts: 2981
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: Trouble with "IF, ELIF, ELSE" Conditions - Error in Syntax

#5 Post by Alex » Wed Apr 07, 2021 11:47 am

cubierocks wrote:
Wed Apr 07, 2021 11:27 am
I changed the placement of the variables, however, I'm still receiving the same message.
'Cause you still use single equal sign to check equality. Should be

Code: Select all

if Burger: # the same as if Burger == True:
viewtopic.php?f=8&t=61827&p=541415#p541411

User avatar
cubierocks
Newbie
Posts: 19
Joined: Sat Nov 03, 2012 11:12 am
Projects: An Everyday Love
itch: hollowrosestudios
Contact:

Re: Trouble with "IF, ELIF, ELSE" Conditions - Error in Syntax

#6 Post by cubierocks » Wed Apr 07, 2021 12:03 pm

Double equal signs result in an "unexpected EOF while parsing" message.
No equal sign (straight to colon) also results in the same error.
Attachments
Screen Shot 2021-04-07 at 12.01.49 PM.png
Screen Shot 2021-04-07 at 11.55.28 AM.png

User avatar
Ocelot
Eileen-Class Veteran
Posts: 1883
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: Trouble with "IF, ELIF, ELSE" Conditions - Error in Syntax

#7 Post by Ocelot » Wed Apr 07, 2021 12:30 pm

Also there is no condition in elif statement. You might want to fix that first and check if error persist.
< < insert Rick Cook quote here > >

User avatar
cubierocks
Newbie
Posts: 19
Joined: Sat Nov 03, 2012 11:12 am
Projects: An Everyday Love
itch: hollowrosestudios
Contact:

Re: Trouble with "IF, ELIF, ELSE" Conditions - Error in Syntax

#8 Post by cubierocks » Wed Apr 07, 2021 12:45 pm

Ah! That's what I was getting wrong. I just needed to go straight to 'if" statements. Thank you, it works fine now!
Attachments
Screen Shot 2021-04-07 at 12.44.17 PM.png

Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot], Ocelot