if statement problem

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:

if statement problem

#1 Post by texasstallion »

Getting an error when trying to add an if statement.

Code: Select all

if energy_point < 0:
    "Not enouph energy"
    jump computer1

elif energy_point > 0 and jap_point = 0 :
    $ energy_point -= 1
    $ jap_point += 1
    jump japlearning1

elif energy_point > 0 and jap_point = 1 :
    $ energy_point -= 1
    $ jap_point += 1
    jump japlearning2

elif energy_point > 0 and jap_point = 2 :
    $ energy_point -= 1
    $ jap_point += 1
    jump japlearning3

elif energy_point > 0 and jap_point = 3 :
    $ energy_point -= 1
    $ jap_point += 1
    jump japlearning4

elif energy_point > 0 and jap_point = 4 :
    $ energy_point -= 1
    $ jap_point += 1
    jump japlearning5

elif energy_point > 0 and jap_point = 5 :
    "Thats all for now check back on the next update"
    jump computer1

Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
  File "game/script.rpy", line 190, in script
    if energy_point <= 0:
SyntaxError: invalid syntax (game/script.rpy, line 194)

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

Full traceback:
  File "game/script.rpy", line 190, in script
    if energy_point <= 0:
  File "E:\new renpy 6-26-2019\renpy-7.3.0-sdk\renpy\ast.py", line 1830, in execute
    if renpy.python.py_eval(condition):
  File "E:\new renpy 6-26-2019\renpy-7.3.0-sdk\renpy\python.py", line 1988, in py_eval
    code = py_compile(code, 'eval')
  File "E:\new renpy 6-26-2019\renpy-7.3.0-sdk\renpy\python.py", line 690, in py_compile
    raise e
SyntaxError: invalid syntax (game/script.rpy, line 194)

Windows-8-6.2.9200
Ren'Py 7.3.0.271
learn japanesse to get 1.0
Tue Jul 16 17:54:38 2019

User avatar
Remix
Eileen-Class Veteran
Posts: 1628
Joined: Tue May 30, 2017 6:10 am
Completed: None... yet (as I'm still looking for an artist)
Projects: An un-named anime based trainer game
Contact:

Re: if statement problem

#2 Post by Remix »

You want == for the exact matches ... e.g. and jap_point == 0:

Fix those and the other error might get resolved
Frameworks & Scriptlets:

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

Re: if statement problem

#3 Post by texasstallion »

yeah that was it thanks

Post Reply

Who is online

Users browsing this forum: Google [Bot], ZianRiyone