If/Else statements

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
Kadius Dar
Newbie
Posts: 22
Joined: Fri Jan 16, 2009 12:20 pm
Projects: Paths of Destiny, Viral-Day: The Beginning
Contact:

If/Else statements

#1 Post by Kadius Dar » Sat Jan 17, 2009 10:38 pm

Ok, it doesn't say exactly if stored numbers can reach into the negatives or not. So here's my question, with a bit of code (assuming that python somewhat functions like C++, mind you, my coding in anything is less than it is with this form of python. So if I come off as a moron, there is a good reason :D ), is it possible to drop a stored number into a negative number, so that it could affect a jump clause later in the game.

Here's an example code snip (not tested, heading to bed, heh):

Code: Select all

label cont1:

        if kaylalove >= 1:
            jump GoodEnd
        else:
            jump BadEnd

label BadEnd:

    "Idiot..."

    if kaylalove = 0:
        jump quit
    else:
        jump kre

label GoodEnd:
    "Goody two shoes..."
    return
    
label kre:
    $ kaylalove -= 1
    if kaylalove <= -1
        jump DeadEnd
    else:
        jump BadEnd2

label quit:
    return

label DeadEnd:
    "You are dead..."

label BadEnd2
    "You lost..."
Also, I have tossed in a few things that I didn't find any info on when it comes to If/Else statements. Such as, is the use of "=" works other than using ">=" or "<="?

Just wondering, as this info is something I need to figure out, however, my mind isn't running even on a half a tank of sleep, so I need to get more. A quick response or brief explination would be appreciated!

User avatar
akemicchi
Veteran
Posts: 465
Joined: Mon Dec 31, 2007 11:22 pm
Projects: Magicians of Delphine, Panaderia: Ensaimada, SweetTooth!, XOXO Droplets
Deviantart: littlebabyshoes
Contact:

Re: If/Else statements

#2 Post by akemicchi » Sat Jan 17, 2009 10:57 pm

Yep, it runs on negative values. :D
Also, I have tossed in a few things that I didn't find any info on when it comes to If/Else statements. Such as, is the use of "=" works other than using ">=" or "<="?
Yes, it does. You'll have to use "==" instead of "=" though, for it to work.

For label cont1, there are too many spaces in that whole block (before "if kaylalove >= 1:...", and ending with "jump BadEnd"). And "if kaylalove <= -1" is missing a colon after it. Just so you know. xD

Post Reply

Who is online

Users browsing this forum: No registered users