Page 1 of 1

if statement problem

Posted: Tue Jul 16, 2019 7:03 pm
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

Re: if statement problem

Posted: Tue Jul 16, 2019 9:07 pm
by Remix
You want == for the exact matches ... e.g. and jap_point == 0:

Fix those and the other error might get resolved

Re: if statement problem

Posted: Wed Jul 17, 2019 5:26 pm
by texasstallion
yeah that was it thanks