Problem with variables

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
neometalero
Regular
Posts: 181
Joined: Sun Oct 23, 2016 3:51 am
Completed: My Dream Sport Dating Simulator, Attack Helicopter Dating Simulator
Projects: My Dream Sport Dating Simulator, Attack Helicopter Dating Simulator
Deviantart: neometalero
Contact:

Problem with variables

#1 Post by neometalero » Tue Oct 25, 2016 3:03 pm

Hi, i want to create a simple If Structure inside a Label , but this error keep apearing

Image

This is my code

first i declare the variable

label start:

#variables de pyton

$ munieca = True

and then i do the if structure


label op7a:
sh1"Llegue hasta aqui, pero no logré encontrar a mi hija"
sh1"No tengo idea donde estará, que voy a hacer?"

#si recogiste o no a la munieca
if munieca == True:
"la variable vale true"
else:
"funco el else tambien porque?"
Any idea why this is happening?

User avatar
Ocelot
Eileen-Class Veteran
Posts: 1883
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: Problem with variables

#2 Post by Ocelot » Tue Oct 25, 2016 3:12 pm

1) Are you sure that you are not loading game, skipping assignment?
2) Are there any non-latin symbols in varaible name, by any chance?
3) Indentation in provided code sample is broken.
4) You do not need to compare it to True. Just if munieca: is enough.
< < insert Rick Cook quote here > >

User avatar
neometalero
Regular
Posts: 181
Joined: Sun Oct 23, 2016 3:51 am
Completed: My Dream Sport Dating Simulator, Attack Helicopter Dating Simulator
Projects: My Dream Sport Dating Simulator, Attack Helicopter Dating Simulator
Deviantart: neometalero
Contact:

Re: Problem with variables

#3 Post by neometalero » Tue Oct 25, 2016 3:52 pm

Ocelot wrote:1) Are you sure that you are not loading game, skipping assignment?
2) Are there any non-latin symbols in varaible name, by any chance?
3) Indentation in provided code sample is broken.
4) You do not need to compare it to True. Just if munieca: is enough.
Tks for your answer. What would be the apropiate indentation for this code?

Also i dont have any non latin simbols in the variable.

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: Problem with variables

#4 Post by trooper6 » Tue Oct 25, 2016 5:00 pm

First off declare your variables using "default" before the start label.
Second, post code using "code" tags rather than "quote" tags so we can see your indentation.
Third, each new level should be indented 4 spaces. So if you have a label, all the things inside that label should be indented for spaced. If you have an if block inside the label, the things inside the if block should be indented 8 spaces, and so on. This is documented here: https://www.renpy.org/doc/html/language ... and-blocks

Fourth, try this:

Code: Select all

default munieca = True

label op7a:
    sh1"Llegue hasta aqui, pero no logré encontrar a mi hija"
    sh1"No tengo idea donde estará, que voy a hacer?"

    #si recogiste o no a la munieca
    if munieca == True:
        "la variable vale true"
    else:
        "funco el else tambien porque?"
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

User avatar
neometalero
Regular
Posts: 181
Joined: Sun Oct 23, 2016 3:51 am
Completed: My Dream Sport Dating Simulator, Attack Helicopter Dating Simulator
Projects: My Dream Sport Dating Simulator, Attack Helicopter Dating Simulator
Deviantart: neometalero
Contact:

Re: Problem with variables

#5 Post by neometalero » Tue Oct 25, 2016 7:34 pm

Tks a lot now everything works. This helped me a lot.
In the wiki of Renpy the variable declaration is not clear.
And tks for the tip on the default , in the wiki says that you need to put the variables with a $, but it doesnt work
Image
Working on My Dream Sport Dating Simulator right now
https://store.steampowered.com/app/1521 ... Simulator/

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: Problem with variables

#6 Post by trooper6 » Wed Oct 26, 2016 1:49 am

Are you looking at the wiki or the online documentation?

The wiki (https://www.renpy.org/wiki/renpy/Wiki_Home_Page) is really out of date and you should not use it.
The online documentation (https://www.renpy.org/doc/html/index.html) is up to date.
Default is documented here: https://www.renpy.org/doc/html/python.h ... -statement
However, I don't think the default statement is documented as well as it could be. I'd note the changelog where the default is first introduced: https://www.renpy.org/doc/html/changelo ... -py-6-99-4
define improvements are also mentioned in the changelog: https://www.renpy.org/doc/html/changelo ... provements
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

User avatar
neometalero
Regular
Posts: 181
Joined: Sun Oct 23, 2016 3:51 am
Completed: My Dream Sport Dating Simulator, Attack Helicopter Dating Simulator
Projects: My Dream Sport Dating Simulator, Attack Helicopter Dating Simulator
Deviantart: neometalero
Contact:

Re: Problem with variables

#7 Post by neometalero » Thu Oct 27, 2016 4:00 pm

Tks for the links , i will check them out
Image
Working on My Dream Sport Dating Simulator right now
https://store.steampowered.com/app/1521 ... Simulator/

Post Reply

Who is online

Users browsing this forum: No registered users