Page 1 of 1

Need help with if statments in my code.

Posted: Sun Feb 27, 2011 8:50 pm
by Sakura02
Ok so I have an image map which is a bulletin board with flyers on it that you can click on. I want it be so when you click on one, you get a menu item which asks if you want to confirm. However i keep getting errors with the if statements. Does thsi work or no

Code: Select all

elif result == "student":
    
    show melonsurprised with vpunch:
        xpos 150 ypos 50
        
    hide melonnya    
    
    m "Huh student council for serious! Fer serious? Who the heck would want to do that??!"
    
    menu:
        "Yes":
            jump Student_Club
        
        "No wait ":
            jump Bulletin_Board
    
elif result == "cook":
    
    show melontalking with dissolve:
        xpos 150 ypos 50
    
    m "Yah! You picked my club! Awesome are you sure?"        

    menu:
        "Yes":
            jump Cooking_Club
        
        "No wait ":
            jump Bulletin_Board
What did I miss? Thnx

Re: Need help with if statments in my code.

Posted: Sun Feb 27, 2011 9:42 pm
by SusanTheCat
Is that the whole snippet?

It should start with an if:

Code: Select all

if result == "student":
    [blah blah blah]
    
elif result == "cook":
    [blah blah blah]

[rest of code]
reference:
http://www.renpy.org/wiki/renpy/doc/ref ... _Statement

Susan

Re: Need help with if statments in my code.

Posted: Sun Feb 27, 2011 9:42 pm
by SusanTheCat
Is that the whole snippet?

It should start with an if:

Code: Select all

if result == "student":
    [blah blah blah]
    
elif result == "cook":
    [blah blah blah]

[rest of code]
reference:
http://www.renpy.org/wiki/renpy/doc/ref ... _Statement

Susan

Re: Need help with if statments in my code.

Posted: Mon Feb 28, 2011 12:20 am
by Sakura02
Thanks for the quick response. Yeah I do have an if statement at the beginning...sorry that was the ending. So what is the difference between 'if' and 'elif' ??

Re: Need help with if statments in my code.

Posted: Mon Feb 28, 2011 1:14 am
by Aleema
elif means "else if", so if the statement above it isn't true, then continue down the line until something is true.

If you want multiple things to appear if enabled, they need to all be Ifs and not Else Ifs. Because "elif" basically means "or".

Please post your errors next time, so we can find out what you're doing wrong.

Re: Need help with if statments in my code.

Posted: Mon Feb 28, 2011 8:41 pm
by Sakura02
YES it works :D Thanks. Sorry next time I'll post the whole error ^_^ I was confused about if and else statements, it's my first time using them.