I'm having an 'if' statement error - invalid syntax? [SOLVED]

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
SplashyDashyBomBashi
Newbie
Posts: 4
Joined: Thu Nov 08, 2018 12:36 pm
Contact:

I'm having an 'if' statement error - invalid syntax? [SOLVED]

#1 Post by SplashyDashyBomBashi » Thu Nov 08, 2018 12:56 pm

So, I'm very very new at this, and I'm not quite sure what to do in this scenario. The full error I'm getting is:
An Exception Has Occurred
file "game/script.rpy", line 252 in script
if variable_race = monster:
Syntax Error: invalid Syntax.

This is the portion I think it's referring to:
if variable_race = "monster":
p "{cps=25}Are you [name] [lastname], the monster registered at Threebrach Avenue, apartment block C-16?{/cps}"
jump areyou1_done

else:
p "{cps=25}Are you [name] [lastname], the mage registered at Threebrach Avenue, apartment block C-16?{/cps}"
jump areyou1_done

label areyou1_done:

I can't figure out how to fix it, though. Can anyone help me?

Edit: I figured it out! Sorry for bothering everybody.
Last edited by SplashyDashyBomBashi on Fri Nov 09, 2018 11:18 am, edited 1 time in total.

User avatar
trooper6
Lemma-Class Veteran
Posts: 3712
Joined: Sat Jul 09, 2011 10:33 pm
Projects: A Close Shave
Location: Medford, MA
Contact:

Re: I'm having an 'if' statement error - invalid syntax?

#2 Post by trooper6 » Thu Nov 08, 2018 1:17 pm

if variable_race == "monster"

= assigns value
== checks value
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)
Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978

rames44
Veteran
Posts: 232
Joined: Sun May 29, 2016 4:38 pm
Contact:

Re: I'm having an 'if' statement error - invalid syntax?

#3 Post by rames44 » Thu Nov 08, 2018 1:18 pm

When doing an “if” test, you need two equals signs, not one. One represents an assignment, not a test.

Code: Select all

If variable_race == “monster”:
    Etc, etc

Post Reply

Who is online

Users browsing this forum: Google [Bot], span4ev