Indentation issue with menu choices.

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
dannythewaiter
Newbie
Posts: 3
Joined: Mon May 16, 2011 7:47 pm
Contact:

Indentation issue with menu choices.

#1 Post by dannythewaiter »

I'm rather new at writing code like this so i'm sorry if this is something blatant and obvious.

When I try to launch the game to test it, i get this message:
File "game/script.rpy", line 47: expected menuitem
(a red arrow)jump choice1_yes

Here is the code for that section.

Code: Select all

menu:
        "Say nothing."
        jump choice1_yes
        
        "Tell her off."
        jump choice1_no
        
        label choice1_yes:
            
            $ menu_flag = True
            
            e "This always happens, Seph..."
            
            jump choice1_done
            
            label choice1_no:
            
            $ menu_flag = False
            
            y "Get out of my face, Elena. You don't understand."
            
            jump choice1_done
            
            label choice1_done:
thank you for your help!

User avatar
Aleema
Lemma-Class Veteran
Posts: 2677
Joined: Fri May 23, 2008 2:11 pm
Organization: happyB
Tumblr: happybackwards
Contact:

Re: Indentation issue with menu choices.

#2 Post by Aleema »

This is how your code is supposed to look (I added a few things for reference):

Code: Select all

label ???:
    menu:
        "Say nothing.":
            jump choice1_yes
        
        "Tell her off.":
            jump choice1_no

label choice1_yes:
    
    $ menu_flag = True
    
    e "This always happens, Seph..."
    
    jump choice1_done
    
label choice1_no:
    
    $ menu_flag = False
    
    y "Get out of my face, Elena. You don't understand."
    
    jump choice1_done
    
label choice1_done:
    ""
For one, you did not have a colon (:) after you menu items. Next, you needed to indent what happens after each menu item over once. Lastly, I fixed the indentation for the subsequent labels.

Also, what you have there doesn't even need multiple labels. Look:

Code: Select all

label ???:
    menu:
        "Say nothing.":
            $ menu_flag = True
            e "This always happens, Seph..."

        "Tell her off.":
            $ menu_flag = False
            y "Get out of my face, Elena. You don't understand."

    ""
    if menu_flag:
        "Flagged"
    ""
But the other way still works. :)

dannythewaiter
Newbie
Posts: 3
Joined: Mon May 16, 2011 7:47 pm
Contact:

Re: Indentation issue with menu choices.

#3 Post by dannythewaiter »

Ahh, thank you so much! Everything works now.

just to clarify, how many spaces is an indent? and thank you again. seriously I was pulling my hair out.

User avatar
Aleema
Lemma-Class Veteran
Posts: 2677
Joined: Fri May 23, 2008 2:11 pm
Organization: happyB
Tumblr: happybackwards
Contact:

Re: Indentation issue with menu choices.

#4 Post by Aleema »

Four spaces is an indent. Luckily, there should be a button on your keyboard called Tab. Just hit that, and it will space things for you automatically.

LVUER
King of Lolies
Posts: 4538
Joined: Mon Nov 26, 2007 9:57 pm
Completed: R.S.P
Location: Bandung, West Java, Indonesia
Contact:

Re: Indentation issue with menu choices.

#5 Post by LVUER »

But aren't we supposed to avoid TAB? Since it could screws your script in some editors.
"Double the princesses, quadruple the fun!" - Haken Browning (SRW-OG Endless Frontier)

DeviantArt Account
MoeToMecha Blog (under construction)
Lolicondria Blog (under construction) <- NSFW

User avatar
Aleema
Lemma-Class Veteran
Posts: 2677
Joined: Fri May 23, 2008 2:11 pm
Organization: happyB
Tumblr: happybackwards
Contact:

Re: Indentation issue with menu choices.

#6 Post by Aleema »

The tab character (what breaks the script) is not what happens when you press the Tab button. At least, not on my keyboard.

LVUER
King of Lolies
Posts: 4538
Joined: Mon Nov 26, 2007 9:57 pm
Completed: R.S.P
Location: Bandung, West Java, Indonesia
Contact:

Re: Indentation issue with menu choices.

#7 Post by LVUER »

Anyway, in general, TAB should be avoided. Except when you're working on a word document and you know you won't changing your word-editor. In programming, we should avoid TAB (at least that's what I and my co-workers always do).
"Double the princesses, quadruple the fun!" - Haken Browning (SRW-OG Endless Frontier)

DeviantArt Account
MoeToMecha Blog (under construction)
Lolicondria Blog (under construction) <- NSFW

User avatar
Aleema
Lemma-Class Veteran
Posts: 2677
Joined: Fri May 23, 2008 2:11 pm
Organization: happyB
Tumblr: happybackwards
Contact:

Re: Indentation issue with menu choices.

#8 Post by Aleema »

I have worked with the Tab key for all of my Ren'Py projects, in both the SciTE and jEdit editors. There have been no ramifications and the key has been nothing but helpful. (Shift+Tab, for instance, moves selections to the left instead of right.) I really can't think of how people would work without the Tab key. Am I missing something entirely?

User avatar
inahochama
Regular
Posts: 39
Joined: Tue Dec 15, 2009 12:38 am
Contact:

Re: Indentation issue with menu choices.

#9 Post by inahochama »

Kind of going ot here but i actually have trouble using the TAB key myself. Most of the time, it gives me troublesome errors for using it so I just stick to the good ol' spacebar.

User avatar
PyTom
Ren'Py Creator
Posts: 16096
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: Indentation issue with menu choices.

#10 Post by PyTom »

It depends on the editor you're using. The editors I've shipped with Ren'Py have been configured to use spaces for indentation, and to indent one step (four spaces) on tab. If you don't have your editor configured this way, it might insert a tab character, which is something Ren'Py doesn't like very much.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

Post Reply

Who is online

Users browsing this forum: Google [Bot], Majestic-12 [Bot]