Indentaion issues?

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
ninethousandpotatoes
Newbie
Posts: 8
Joined: Sat Jan 10, 2015 4:14 am
Contact:

Indentaion issues?

#1 Post by ninethousandpotatoes »

This is my first time making a game with ren'py, and I don't know how to fix this.

Code: Select all

scene about_to_leave
    t "Okay, class will end in five minutes, please pack your things."
        "You pass your note to Kiki hastily." if selection == "kiki_noteg":
        "You pass your note to Puki hastily." if selection == "puki_noteg":
        "You pass your note to Naname hastily." if selection == "naname_noteg":
        "You pass your note to Hiro hastiy." if selection == "hiro_noteg":
        "You pass your note to Ameko hastily." if selection == "ameko_noteg":
        "You pass your note to Irashi hastily." if selection == "irashi_noteg":
Attachments
problem.PNG

philat
Eileen-Class Veteran
Posts: 1926
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: Indentaion issues?

#2 Post by philat »

Change it to the following (etc.)

Code: Select all

scene about_to_leave
    t "Okay, class will end in five minutes, please pack your things."
        if selection == "kiki_noteg":
            "You pass your note to Kiki hastily." if selection == "kiki_noteg":

ninethousandpotatoes
Newbie
Posts: 8
Joined: Sat Jan 10, 2015 4:14 am
Contact:

Re: Indentaion issues?

#3 Post by ninethousandpotatoes »

I think I fixed it, but it's still not working right.

Code: Select all

scene about_to_leave
    t "Okay, class will end in five minutes, please pack your things."
        if selection == "kiki_noteg":
            "You pass your note to Kiki hastily." if selection == "kiki_noteg":
        if selection == "puki_noteg":
            "You pass your note to Puki hastily." if selection == "puki_noteg":
        if selection == "naname_noteg":
            "You pass your note to Naname hastily." if selection == "naname_noteg":
        if selection == "hiro_noteg":
            "You pass your note to Hiro hastiy." if selection == "hiro_noteg":
        if selection == "ameko_noteg":
            "You pass your note to Ameko hastily." if selection == "ameko_noteg":
        if selection == "irashi_noteg":
            "You pass your note to Irashi hastily." if selection == "irashi_noteg":
Attachments
problem.PNG

User avatar
Yuuji
Regular
Posts: 96
Joined: Tue Jan 20, 2015 3:08 am
Location: Russia, Perm
Contact:

Re: Indentaion issues?

#4 Post by Yuuji »

When you write the new block of code(for example, in 'if' statement or 'label' statement) you should add indentation. In other cases it will cause the error. Well, maybe I've written something unclear, because my english is bad, so, if someone have seen any mistakes in my message, please tell about it :) Try this code:

Code: Select all

scene about_to_leave
t "Okay, class will end in five minutes, please pack your things."
if selection == "kiki_noteg":
    "You pass your note to Kiki hastily."
if selection == "puki_noteg":
    "You pass your note to Puki hastily."
if selection == "naname_noteg":
    "You pass your note to Naname hastily."
if selection == "hiro_noteg":
    "You pass your note to Hiro hastiy."
if selection == "ameko_noteg":
    "You pass your note to Ameko hastily."
if selection == "irashi_noteg":
    "You pass your note to Irashi hastily."
There's no point in standing around with your mouth open waiting for talent to fall from the sky. You make your own. No matter what you're doing, the most essential thing is not to give up.

ninethousandpotatoes
Newbie
Posts: 8
Joined: Sat Jan 10, 2015 4:14 am
Contact:

Re: Indentaion issues?

#5 Post by ninethousandpotatoes »

I did that and then this error message came up
Attachments
problem.PNG

User avatar
shivanshs9
Regular
Posts: 54
Joined: Sun Jul 20, 2014 1:59 pm
Projects: The Destiny(http://thedestiny-cxz.blogspot.com)
Organization: Cyber-X-Zone
Location: India
Contact:

Re: Indentaion issues?

#6 Post by shivanshs9 »

Did you try Yuuji's code? Follow Yuuji's example and everything should work fine. Also, in my opinion, only one of those lines should display, right? Then, maybe you should modify Yuuji's code as this:

Code: Select all

scene about_to_leave
t "Okay, class will end in five minutes, please pack your things."
if selection == "kiki_noteg":
    "You pass your note to Kiki hastily."
elif selection == "puki_noteg":
    "You pass your note to Puki hastily."
elif selection == "naname_noteg":
    "You pass your note to Naname hastily."
elif selection == "hiro_noteg":
    "You pass your note to Hiro hastily."
elif selection == "ameko_noteg":
    "You pass your note to Ameko hastily."
elif selection == "irashi_noteg":
    "You pass your note to Irashi hastily."
"Destiny is a no matter of chance
It is a matter of choice
It is not a thing to be waited for
It is a thing to be achieved..."

-William Jennings Bryan
If you can dream and not make dreams your master;
If you can think and not make thoughts your aim,
If you can meet with Triumph and Disaster;
And treat those two impostors just the same,
Only then can you ever win against yourself...

User avatar
Yuuji
Regular
Posts: 96
Joined: Tue Jan 20, 2015 3:08 am
Location: Russia, Perm
Contact:

Re: Indentaion issues?

#7 Post by Yuuji »

Can you give me more of your code? Maybe you somewhere did a mistake. This code works:

Code: Select all

label start:
    scene bg1 #this is just sample background
    "Okay, class will end in five minutes, please pack your things."
    "You pass your note to Kiki hastily." 
    $selection = "puki_noteg" #'selection' should be initialized before using
    if selection == "kiki_noteg": 
        e "You pass your note to Puki hastily." 
    if selection == "puki_noteg": 
        e "You pass your note to Naname hastily." 
    if selection == "naname_noteg": 
        e "You pass your note to Hiro hastiy." 
    if selection == "hiro_noteg": 
        e "You pass your note to Ameko hastily." 
There's no point in standing around with your mouth open waiting for talent to fall from the sky. You make your own. No matter what you're doing, the most essential thing is not to give up.

User avatar
Yuuji
Regular
Posts: 96
Joined: Tue Jan 20, 2015 3:08 am
Location: Russia, Perm
Contact:

Re: Indentaion issues?

#8 Post by Yuuji »

shivanshs9 wrote:Then, maybe you should modify Yuuji's code as this:
Yeah, you code is more optimizied, so it'd be better to use it.
There's no point in standing around with your mouth open waiting for talent to fall from the sky. You make your own. No matter what you're doing, the most essential thing is not to give up.

philat
Eileen-Class Veteran
Posts: 1926
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: Indentaion issues?

#9 Post by philat »

My bad, I meant to delete the if statement coming at the end of the line and forgot to.

Just to be perfectly explicit, use the if statement followed by a colon, line break, indent, and then DON'T repeat the if statement at the end of the dialogue string. Or, you know, copy/paste.

I don't think it really makes a difference whether you use elif vs. if in this context -- as the variable 'selection' can only be one thing at a time.

User avatar
shivanshs9
Regular
Posts: 54
Joined: Sun Jul 20, 2014 1:59 pm
Projects: The Destiny(http://thedestiny-cxz.blogspot.com)
Organization: Cyber-X-Zone
Location: India
Contact:

Re: Indentaion issues?

#10 Post by shivanshs9 »

Hmm... Yuuji, your code's kinda confusing:

Code: Select all

label start:
    scene bg1 #this is just sample background
    "Okay, class will end in five minutes, please pack your things."

    "You pass your note to Kiki hastily."  # <- This line means that it will always display, no matter what
    $selection = "puki_noteg" #'selection' should be initialized before using
    # I think selection is already defined in a previous menu(my guess), so aren't you overwriting the value?

    if selection == "kiki_noteg": 
        e "You pass your note to Puki hastily." 
    if selection == "puki_noteg": 
        e "You pass your note to Naname hastily." 
    if selection == "naname_noteg": 
        e "You pass your note to Hiro hastiy." 
    if selection == "hiro_noteg": 
        e "You pass your note to Ameko hastily." 
I don't think you should find too much mistakes in your code, since your previous posted code was fine and had no errors... Just relax and think of the ways the questioner could have gone wrong, instead of saying "my code must be the culprit here!" This advice can help long way into the future! :smile:
"Destiny is a no matter of chance
It is a matter of choice
It is not a thing to be waited for
It is a thing to be achieved..."

-William Jennings Bryan
If you can dream and not make dreams your master;
If you can think and not make thoughts your aim,
If you can meet with Triumph and Disaster;
And treat those two impostors just the same,
Only then can you ever win against yourself...

User avatar
Yuuji
Regular
Posts: 96
Joined: Tue Jan 20, 2015 3:08 am
Location: Russia, Perm
Contact:

Re: Indentaion issues?

#11 Post by Yuuji »

shivanshs9 wrote: Just relax and think of the ways the questioner could have gone wrong, instead of saying "my code must be the culprit here!"
Okay, thanks for advice :) I had to test my code so I've overwritten the variable. I've just posted code that works for me.
There's no point in standing around with your mouth open waiting for talent to fall from the sky. You make your own. No matter what you're doing, the most essential thing is not to give up.

Post Reply

Who is online

Users browsing this forum: Amazon [Bot], Google [Bot]