Ren'Py ignores my variables! *problem solved*

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
ushida_hikaru16
Newbie
Posts: 5
Joined: Wed Jul 13, 2011 1:27 am
Contact:

Ren'Py ignores my variables! *problem solved*

#1 Post by ushida_hikaru16 »

My question is about python ($) choice variables in Ren'Py.

I want to have the player character react differently at different parts of the story depending on which selection is chosen in the first menu of the game.

This is the first menu, along with the variable I want to declare:

Code: Select all

label reaction:
    $ angry_rage_child = False
    
    menu:
        "...Come again?":
            i "I'm sorry, Mom...could you repeat that please?"
            $ angry_rage_child == False
            jump trip_time
        
        "... ... ...wut??":
            $ angry_rage_child == False
            jump dumbfounded
        
        "NO!!!!!!! DX":
            $ angry_rage_child == True
            jump rage
I declared the variable True for the final selection, however, later on when I call where I want the change to be implemented -

Code: Select all

if angry_rage_child == True :
    jump plot
if angry_rage_child == False :
    jump shikata_ga_nai
- Ren'Py ignores it completely and simply continues through to the next label, even though the angry main character scenario was selected back in the first menu!!

What am I doing wrong? Does calling the variable have to be part of a new menu or something? I don't understand why it won't jump to the part of the script I want it to based on the user's selection. It's getting on my nerve.

So...help? Someone?
Last edited by ushida_hikaru16 on Sun Jul 24, 2011 3:04 am, edited 1 time in total.

User avatar
Camille
Eileen-Class Veteran
Posts: 1227
Joined: Sat Apr 23, 2011 2:43 pm
Completed: Please see http://trash.moe
Projects: the head well lost
Organization: L3
Tumblr: narihira
Deviantart: crownwaltz
itch: lore
Contact:

Re: Ren'Py ignores my variables! What am I doing wrong?

#2 Post by Camille »

Should be like this:

Code: Select all

label reaction:
    $ angry_rage_child = False
    
    menu:
        "...Come again?":
            i "I\'m sorry, Mom...could you repeat that please?"
            $ angry_rage_child = False
            jump trip_time
        
        "... ... ...wut??":
            $ angry_rage_child = False
            jump dumbfounded
        
        "NO!!!!!!! DX":
            $ angry_rage_child = True
            jump rage

Code: Select all

if angry_rage_child == True:
    jump plot
elif angry_rage_child == False:
    jump shikata_ga_nai
Basically, just some syntax mistakes. When you're setting the variables in your labels, you only use one = sign.

ushida_hikaru16
Newbie
Posts: 5
Joined: Wed Jul 13, 2011 1:27 am
Contact:

Re: Ren'Py ignores my variables! What am I doing wrong?

#3 Post by ushida_hikaru16 »

Oh, it's an else/if...yikes. I would have never known that. I also would have never known to use only one "=" initially. Okay.

Thanks! That was a big help. I'm obviously a newbie, so still learning (and the little bit of programming knowledge I have is in C++, not Python... >///<).

Thanks again. : )

User avatar
scorlight
Regular
Posts: 67
Joined: Fri Sep 13, 2013 7:02 am
Contact:

Re: Ren'Py ignores my variables! *problem solved*

#4 Post by scorlight »

Wow, thanks a lot! I have the same problem like her too ^^
Artist for rent, see my art here: http://scorlight.deviantart.com/gallery/

User avatar
trooper6
Lemma-Class Veteran
Posts: 3712
Joined: Sat Jul 09, 2011 10:33 pm
Projects: A Close Shave
Location: Medford, MA
Contact:

Re: Ren'Py ignores my variables! *problem solved*

#5 Post by trooper6 »

Python/Renpy does this the same way as Java does it, "=" is used to assign, "==" is used to check equivalency.

So, for me, in my mind, when I type up a line, this is what I say in my head:

a = "crazy" (a is assigned the value of "crazy")
a == "crazy" (a is the same as "crazy")
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)
Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978

Post Reply

Who is online

Users browsing this forum: Google [Bot]