If Statement in Label

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
User avatar
wyverngem
Miko-Class Veteran
Posts: 615
Joined: Mon Oct 03, 2011 7:27 pm
Completed: Simple as Snow, Lady Luck's Due,
Projects: Aether Skies, Of the Waterfall
Tumblr: casting-dreams
itch: castingdreams
Location: USA
Contact:

If Statement in Label

#1 Post by wyverngem »

^^; Easy fix, right? What am I doing wrong in this if else statement? I've already defined $ stamina in an int block. It's a part of a label.

Code: Select all

    if stamina =>50:
        "You can't craft."
        jump start
    else:
        show crafting
        call screen SliderDifficult
        $ stamina - 50
        if _return == 1 or _return == 4:
            jump green
        else:
            jump red
Here's the Traceback

Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
  File "game/script.rpy", line 144, in script
SyntaxError: invalid syntax (game/script.rpy, line 144)

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

Full traceback:
  File "C:\Users\Emilie\Desktop\My Visual Novel\renpy-6.13.12\renpy\execution.py", line 265, in run
  File "C:\Users\Emilie\Desktop\My Visual Novel\renpy-6.13.12\renpy\ast.py", line 1374, in execute
  File "C:\Users\Emilie\Desktop\My Visual Novel\renpy-6.13.12\renpy\python.py", line 1009, in py_eval
  File "C:\Users\Emilie\Desktop\My Visual Novel\renpy-6.13.12\renpy\python.py", line 259, in py_compile
SyntaxError: invalid syntax (game/script.rpy, line 144)

Windows-7-6.1.7601-SP1
Ren'Py 6.13.12.1728
A Ren'Py Game 0.0

User avatar
Alex
Lemma-Class Veteran
Posts: 3094
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: If Statement in Label

#2 Post by Alex »

You need to do something with <$ stamina - 50> (isn't it $ stamina -= 50 or $ stamina = 50 ?).

Code: Select all

if stamina =>50:
        "You can't craft."
        jump start
else:
        show crafting
        call screen SliderDifficult
        $ stamina = 50
        if _return == 1 or _return == 4:
            jump green
        else:
            jump red

redeyesblackpanda
Eileen-Class Veteran
Posts: 1006
Joined: Thu Dec 22, 2011 4:26 am
Projects: Eternal Memories, plot bunnies that won't die.
Organization: HellPanda Studios
Location: United States
Contact:

Re: If Statement in Label

#3 Post by redeyesblackpanda »

What Alex said. Besides that, I've never seen an inequality written as "=>" I haven't tested it, but I think you want to use inequalities written in this "<=" or this ">=" fashion.
(All projects currently on a hiatus of sorts. I blame life.)
Tsundere VN
Not really checking the forums any more due to time constraints, so if you want to contact me, PM. I'll get a notification and log in. :mrgreen:
Also, I've been hit and run posting, which means I don't see many replies. If you want to respond to something I've said, also feel free to PM me.

NOTE: if you've got questions about vnovel or things like that, it's Leon that you should be contacting. Leon's been pretty much handling everything, but due to various reasons, I've had to withdraw entirely.

User avatar
wyverngem
Miko-Class Veteran
Posts: 615
Joined: Mon Oct 03, 2011 7:27 pm
Completed: Simple as Snow, Lady Luck's Due,
Projects: Aether Skies, Of the Waterfall
Tumblr: casting-dreams
itch: castingdreams
Location: USA
Contact:

Re: If Statement in Label

#4 Post by wyverngem »

*smacks head* Simple as reversing the signs and adding an "=" to the -50. So tired. Thank you...

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot], MisterPinetree