If statement syntax error

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
Jayla426
Newbie
Posts: 4
Joined: Thu Jan 31, 2019 3:49 pm
Contact:

If statement syntax error

#1 Post by Jayla426 »

In my game, I'm trying to get a character to say a certain thing depending on what the player chose to do previously. Like, if the player went to the meeting right away, the character would praise her. If she went to go hang out with someone else, either Maria or Anthony because she has the choice to either go to the meeting, hangout with Maria or hangout with Anthony, the character, James, would be a bit annoyed. except i keep getting a syntax error. It says:

Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
  File "game/script.rpy", line 77, in script
    if <visiting_maria> == True:
SyntaxError: invalid syntax (game/script.rpy, line 77)

-- Full Traceback ------------------------------------------------------------

Full traceback:
  File "game/script.rpy", line 77, in script
    if < visiting_maria > == True:
  File "C:\Users\zakoo\Desktop\renpy-7.1.1-sdk\renpy\ast.py", line 1760, in execute
    if renpy.python.py_eval(condition):
  File "C:\Users\zakoo\Desktop\renpy-7.1.1-sdk\renpy\python.py", line 1942, in py_eval
    code = py_compile(code, 'eval')
  File "C:\Users\zakoo\Desktop\renpy-7.1.1-sdk\renpy\python.py", line 674, in py_compile
    raise e
SyntaxError: invalid syntax (game/script.rpy, line 77)

Windows-8-6.2.9200
Ren'Py 7.1.1.929
Yellow Roses And Silver Knives 1.0
Tue May 21 17:45:35 2019
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
my code is :

label meeting_with_james:
if < visiting_maria > == True:
scene bg meeting room
show James tied calm
Js "Oh, %(player_name)s , you took your time coming here."
pov "Hello James, so what is this meeting about?"
else:
scene bg meeting room
show James tied calm
Js "Ah %(player_name)s , thank you for coming here right away. I appreciate your punctuality."
if <visiting_anthony> == True:
scene bg meeting room
show James tied calm
Js "Oh, %(player_name)s , you took your time coming here."
pov "Hello James, so what is this meeting about?"
else:
scene bg meeting room
show James tied calm
Js "Ah %(player_name)s , thank you for coming here right away. I appreciate your punctuality."
return
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

I have no error for the "visiting_anthony" if statement, despite it being the exact same as the "visiting_maria" if statement. Is anyone able to help me figure out what's my error?

User avatar
Per K Grok
Miko-Class Veteran
Posts: 882
Joined: Fri May 18, 2018 1:02 am
Completed: the Ghost Pilot, Sea of Lost Ships, Bubbles and the Pterodactyls, Defenders of Adacan Part 1-3, the Phantom Flyer
itch: per-k-grok
Location: Sverige
Contact:

Re: If statement syntax error

#2 Post by Per K Grok »

Jayla426 wrote: Tue May 21, 2019 6:04 pm In my game, I'm trying to get a character to say a certain thing depending on what the player chose to do previously. Like, if the player went to the meeting right away, the character would praise her. If she went to go hang out with someone else, either Maria or Anthony because she has the choice to either go to the meeting, hangout with Maria or hangout with Anthony, the character, James, would be a bit annoyed. except i keep getting a syntax error. It says:

Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
  File "game/script.rpy", line 77, in script
    if <visiting_maria> == True:
SyntaxError: invalid syntax (game/script.rpy, line 77)

-- Full Traceback ------------------------------------------------------------

Full traceback:
  File "game/script.rpy", line 77, in script
    if < visiting_maria > == True:
  File "C:\Users\zakoo\Desktop\renpy-7.1.1-sdk\renpy\ast.py", line 1760, in execute
    if renpy.python.py_eval(condition):
  File "C:\Users\zakoo\Desktop\renpy-7.1.1-sdk\renpy\python.py", line 1942, in py_eval
    code = py_compile(code, 'eval')
  File "C:\Users\zakoo\Desktop\renpy-7.1.1-sdk\renpy\python.py", line 674, in py_compile
    raise e
SyntaxError: invalid syntax (game/script.rpy, line 77)

Windows-8-6.2.9200
Ren'Py 7.1.1.929
Yellow Roses And Silver Knives 1.0
Tue May 21 17:45:35 2019
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
my code is :

label meeting_with_james:
if < visiting_maria > == True:
scene bg meeting room
show James tied calm
Js "Oh, %(player_name)s , you took your time coming here."
pov "Hello James, so what is this meeting about?"
else:
scene bg meeting room
show James tied calm
Js "Ah %(player_name)s , thank you for coming here right away. I appreciate your punctuality."
if <visiting_anthony> == True:
scene bg meeting room
show James tied calm
Js "Oh, %(player_name)s , you took your time coming here."
pov "Hello James, so what is this meeting about?"
else:
scene bg meeting room
show James tied calm
Js "Ah %(player_name)s , thank you for coming here right away. I appreciate your punctuality."
return
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

I have no error for the "visiting_anthony" if statement, despite it being the exact same as the "visiting_maria" if statement. Is anyone able to help me figure out what's my error?
try:
if visiting_maria == True:

'<' and '>' are operators used to compare two values (smaller than or greater than).

Jayla426
Newbie
Posts: 4
Joined: Thu Jan 31, 2019 3:49 pm
Contact:

Re: If statement syntax error

#3 Post by Jayla426 »

thank you! it worked

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Dark12ose, Google [Bot], Sugar_and_rice