(Solved) getting invalid 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
texasstallion
Regular
Posts: 33
Joined: Tue Jun 27, 2017 4:11 pm
Contact:

(Solved) getting invalid syntax

#1 Post by texasstallion »

Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
  File "game/script.rpy", line 732, in script
    if g3_point <=5 :
SyntaxError: invalid syntax (game/script.rpy, line 734)

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

Full traceback:
  File "game/script.rpy", line 732, in script
    if g3_point <=5 :
  File "C:\Users\d5.d257\Downloads\renpy-7.3.2-sdk\renpy\ast.py", line 1830, in execute
    if renpy.python.py_eval(condition):
  File "C:\Users\d5.d257\Downloads\renpy-7.3.2-sdk\renpy\python.py", line 2033, in py_eval
    code = py_compile(code, 'eval')
  File "C:\Users\d5.d257\Downloads\renpy-7.3.2-sdk\renpy\python.py", line 690, in py_compile
    raise e
SyntaxError: invalid syntax (game/script.rpy, line 734)

Windows-8-6.2.9200
Ren'Py 7.3.2.320
jo 1.0
Tue Aug 20 17:04:23 2019

Code: Select all

label bethtalk:
hide scienceTeacher
show beth_happy

if g3_point <=5 :
    jump bethtalkintro
elif g3_point >=5 and if g3_point <=20 :
    jump bethtalk1
elif g3_point >=20 and if g3_point <60 :
    jump bethtalk2
elif g3_point >=60 and if g3_point <100 :
    jump bethtalk3
elif g3_point >=100 and if g3_point <150 :
    jump bethtalk4
elif g3_point >=150 and if g3_point <200 :
    jump bethtalk5
elif g3_point >=200 and if g3_point <10000 :
    jump bethtalk6
else:
        jump science1
Last edited by texasstallion on Wed Aug 21, 2019 5:28 pm, edited 1 time in total.

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

Re: getting invalid syntax

#2 Post by rayminator »

take out the < use a + or - I don't think using < will do anything at all but give errors haven't seen anybody using that in their games before

this might be wrong as well

just to let you know that I'm only at a beginners level so I might be wrong.

Code: Select all

if g3_point = 5:

Code: Select all

elif g3_point += 200 and if g3_point = 10000:
elif g3_point -= 200 and if g3_point = 10000:

User avatar
namastaii
Eileen-Class Veteran
Posts: 1350
Joined: Mon Feb 02, 2015 8:35 pm
Projects: Template Maker for Ren'Py, What Life
Github: lunalucid
Skype: Discord: lunalucid#1991
Soundcloud: LunaLucidMusic
itch: lunalucid
Location: USA
Contact:

Re: getting invalid syntax

#3 Post by namastaii »

Uh, well.. += and -= is for increasing and decreasing a numeric variable. A <= or >= is saying "less than or equal to" or "greater than or equal to" - it is a comparison command.

You have some improper indentation and spacing.

Code: Select all

label bethtalk:
    hide scienceTeacher
    show beth_happy

    if g3_point <=5:
        jump bethtalkintro
    elif g3_point >=5 and if g3_point <=20:
        jump bethtalk1
    elif g3_point >=20 and if g3_point <60:
        jump bethtalk2
    elif g3_point >=60 and if g3_point <100:
        jump bethtalk3
    elif g3_point >=100 and if g3_point <150:
        jump bethtalk4
    elif g3_point >=150 and if g3_point <200:
        jump bethtalk5
    elif g3_point >=200 and if g3_point <10000:
        jump bethtalk6
    else:
        jump science1

drKlauz
Veteran
Posts: 239
Joined: Mon Oct 12, 2015 3:04 pm
Contact:

Re: getting invalid syntax

#4 Post by drKlauz »

Remove extra ifs from conditions.

Code: Select all

if g3_point <=5 :
    jump bethtalkintro
elif g3_point >=5 and g3_point <=20 :
    jump bethtalk1
...
else:
        jump science1
Also it may be easier to read next way:

Code: Select all

if g3_point<=5:
    jump bethtalkintro
elif 5<g3_point<=20:
    jump bethtalk1
...
else:
    jump science1
I may be available for hire, check my thread: viewtopic.php?f=66&t=51350

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

Re: getting invalid syntax

#5 Post by rayminator »

namastaii wrote: Wed Aug 21, 2019 12:06 am Uh, well.. += and -= is for increasing and decreasing a numeric variable. A <= or >= is saying "less than or equal to" or "greater than or equal to" - it is a comparison command.
Oh okay that's for clearing that out for me I wasn't 100% sure

thanks

texasstallion
Regular
Posts: 33
Joined: Tue Jun 27, 2017 4:11 pm
Contact:

Re: getting invalid syntax

#6 Post by texasstallion »

Thanks everyone, removing the extra if was the cause. Also fixed the indentation, the indentations were only like that because i was trying to find out where i messed up and thought it was because they were not spouse to be together.

Post Reply

Who is online

Users browsing this forum: AvalonMelody