Hiding Menu Options Issue

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
FruitSeller
Newbie
Posts: 19
Joined: Sun Jun 22, 2014 2:46 pm
Contact:

Hiding Menu Options Issue

#1 Post by FruitSeller » Sun Jun 22, 2014 6:05 pm

Alright, the newbie is back with problems again. ;-;

Now, I'm very new to ren'py so that might explain why I'm really bad at this. Anyway, I've been having this issue in which I cannot seem to hide or show a menu option correctly. I don't really know how to explain it so I'll just give you the complaint :

Code: Select all

I'm sorry, but errors were detected in your script. Please correct the
errors listed below, and try again.


File "game/script.rpy", line 192: expected menuitem
    if name_leta == True:
    ^

Ren'Py Version: Ren'Py 6.17.6.512

Yeah. Now, I'll show you the coding.

Code: Select all

label menu1:
       menu:
         if name_leta == True:
           "What's with your name?"
               "Emilylacee" "What's with your name?" 
               "Leta" "What do you mean?"
               "Emilylacee" "Well... it's not exactly a foruming username."
               "Leta" "So?"
               "Emilylacee" "I mean, you must have been one of the first um, submissions..."
               "Leta" "I still don't get your point."
               "She's obviously clueless, I can see."
               "Emilylacee" "Never mind, it's nothing."
               $ name_leta == False
               jump menu1
 


            
         if uniform == True: 
          "I'm just wondering - do we have uniforms?"

               "I had been wondering about the uniform issue for a while now." 
               "Emilylacee" "Alright - do we need to wear uniforms."
               "Leta" "Uniform is manditory. However, males have no uniform and are strictly permitted to wear certain types of clothing - we aren't necessarily told what exactly - since we're women."
               "Emilylacee" "What? Seriously, they don't wear a uniform but we have to?"
               "Leta" "The dress code is very strict."
               "Emilylacee" "I guess..." 
               $ uniform == False
               "Leta" "Anymore questions, Emilylacee?" 
         if houses == True:           
          "What's with the houses?"
            "I ask about the houses."
            "Emilylacee" "What's with the weird house names? Are we sorted in them for specific reasons?"
            "Leta smirks."
            "Leta" "House 5 is the undecided group - our actions, grades and several other factors decide if we go up or down. Our dorms don't changed if we get removed from our ranking, though."
            "Leta" "The highest you can be in is House 1 - it's pretty much for the most amazing people around."
            "Leta" "...However, there is another group even more prestigious than House 1 - it's shrouded in mystery."
            "Emilylacee" "What do you mean?"
            "Leta" "The name is House L, nobody really knows anything about it."
            "Leta" "Anyway, the lowest house ranking you can get is House 10 - I don't know how the hell you get there, but once you're there, you're expelled."
            "Emilylacee" "Seems fair, I suppose."
            "Leta" "Yes, very fair."
            $ houses == False
            "Leta" "...Anymore questions, Emilylacee?"
            jump menu1
                  

          "That's all."
            jump d

;-;
If somebody could point out the errors I have made I would feel like giving you the whole world!~

I made another thread before, but that was because of a different problem I had a couple of hours ago and now another has arisen ;-;

Thank you. ;~;

User avatar
Googaboga
Eileen-Class Veteran
Posts: 1383
Joined: Wed Dec 12, 2012 1:37 pm
Completed: https://gbpatch.itch.io/
Projects: Floret Bond, XOXO Blood Droplets, Our Life
Organization: GB Patch Games
Tumblr: gb-patch
itch: gbpatch
Contact:

Re: Hiding Menu Options Issue

#2 Post by Googaboga » Sun Jun 22, 2014 6:13 pm

Try this:

Code: Select all

]label menu1:
       menu:
         "What's with your name?" if name_leta == True:
               "Emilylacee" "What's with your name?"
Instead of this:

Code: Select all

]label menu1:
       menu:
         if name_leta == True:
           "What's with your name?"
               "Emilylacee" "What's with your name?"
For all the menu options with 'if <insert thing here> == True'.
[I'm not sure if I got the padding right ^^;. Just move the if part to the same line as the menu option.]

That's the first thing I noticed but I'll look some more at the code.
In-Progress:
Floret Bond, XOXO Blood Droplets, Our Life
Released:
A Foretold Affair, My Magical Divorce Bureau, XOXO Droplets, Lake of Voices

FruitSeller
Newbie
Posts: 19
Joined: Sun Jun 22, 2014 2:46 pm
Contact:

Re: Hiding Menu Options Issue

#3 Post by FruitSeller » Sun Jun 22, 2014 6:48 pm

Googaboga wrote:Try this:

Code: Select all

]label menu1:
       menu:
         "What's with your name?" if name_leta == True:
               "Emilylacee" "What's with your name?"
Instead of this:

Code: Select all

]label menu1:
       menu:
         if name_leta == True:
           "What's with your name?"
               "Emilylacee" "What's with your name?"
For all the menu options with 'if <insert thing here> == True'.
[I'm not sure if I got the padding right ^^;. Just move the if part to the same line as the menu option.]

That's the first thing I noticed but I'll look some more at the code.
Thank you! c:
I'll go try that out

FruitSeller
Newbie
Posts: 19
Joined: Sun Jun 22, 2014 2:46 pm
Contact:

Re: Hiding Menu Options Issue

#4 Post by FruitSeller » Sun Jun 22, 2014 7:20 pm

Grr, now it's giving me a syntax error.

The piece of code's current state :

Code: Select all

label menu1:
    menu:
         "Ask about her name" if name_leta == True:
               "Emilylacee" "What's with your name?"     
               "Leta" "What do you mean?"
               "Emilylacee" "Well... it's not exactly a foruming username."
               "Leta" "So?"
               "Emilylacee" "I mean, you must have been one of the first um, submissions..."
               "Leta" "I still don't get your point."
               "She's obviously clueless, I can see."
               "Emilylacee" "Nevermind, it's nothing."
               $ name_leta == False
               jump menu1
 
         "Ask about uniforms" if uniform == True:

               "I had been wondering about the uniform issue for a while now." 
               "Emilylacee" "Alright - do we need to wear uniforms?"
               "Leta" "Uniform is manditory. However, males have no uniform and are strictly permitted to wear certain types of clothing - we aren't nessacerily told what exactly - since we're women."
               "Emilylacee" "What? Seriously, they don't wear a uniform but we have to?"
               "Leta" "The dresscode is very strict."
               "Emilylacee" "I guess..." 
               $ uniform == False
               "Leta" "Anymore questions, Emilylacee?" 
               
         "Ask about houses" if houses == True:
            "I ask about the houses."
            "Emilylacee" "What's with the weird house names? Are we sorted in them for specific reasons?"
            "Leta smirks."
            "Leta" "House 5 is the undecided group - our actions, grades and several other factors decide if we go up or down. Our dorms don't changed if we get removed from our ranking, though."
            "Leta" "The highest you can be in is House 1 - it's pretty much for the most amazing people around."
            "Leta" "...However, there is another group even more prestigious than House 1 - it's shrouded in mystery."
            "Emilylacee" "What do you mean?"
            "Leta" "The name is House L, nobody really knows anything about it."
            "Leta" "Anyway, the lowest house ranking you can get is House 10 - I don't know how the hell you get there, but once you're there, you're expelled."
            "Emilylacee" "Seems fair, I suppose."
            "Leta" "Yes, very fair."
            $ houses == False
            "Leta" "...Anymore questions, Emilylacee?"
            jump menu1
                  

         "That's all." if thats_all = True:
            jump d

And the error message :

Code: Select all

 I'm sorry, but an uncaught exception occurred.

While running game code:
  File "game/script.rpy", line 192, in script
    menu:
SyntaxError: invalid syntax (game/script.rpy, line 233)

;-;

I was never meant for coding. ;-;

I'm going to try to fix it but having some wiser eyes would likely solve it much quicker.

Thanks again c:

User avatar
Googaboga
Eileen-Class Veteran
Posts: 1383
Joined: Wed Dec 12, 2012 1:37 pm
Completed: https://gbpatch.itch.io/
Projects: Floret Bond, XOXO Blood Droplets, Our Life
Organization: GB Patch Games
Tumblr: gb-patch
itch: gbpatch
Contact:

Re: Hiding Menu Options Issue

#5 Post by Googaboga » Sun Jun 22, 2014 7:29 pm

At the end it says:

Code: Select all

"That's all." if thats_all = True:
            jump d
Instead of:

Code: Select all

"That's all." if thats_all == True:
            jump d
I'm not sure if that's the main problem but missing an = is a type of syntax error.

And don't worry. Everybody has to start somewhere.
Image
In-Progress:
Floret Bond, XOXO Blood Droplets, Our Life
Released:
A Foretold Affair, My Magical Divorce Bureau, XOXO Droplets, Lake of Voices

FruitSeller
Newbie
Posts: 19
Joined: Sun Jun 22, 2014 2:46 pm
Contact:

Re: Hiding Menu Options Issue

#6 Post by FruitSeller » Sun Jun 22, 2014 7:35 pm

Googaboga wrote:At the end it says:

Code: Select all

"That's all." if thats_all = True:
            jump d
Instead of:

Code: Select all

"That's all." if thats_all == True:
            jump d
I'm not sure if that's the main problem but missing an = is a type of syntax error.

And don't worry. Everybody has to start somewhere.
Image
Thank you! Somehow, that fixed it.

Now, with my game reporting no errors this is the outcome :

It completely ignores the menu and beyond and it closes to the title right before the menu.

;-;
But thank you for helping so far! c:

User avatar
Googaboga
Eileen-Class Veteran
Posts: 1383
Joined: Wed Dec 12, 2012 1:37 pm
Completed: https://gbpatch.itch.io/
Projects: Floret Bond, XOXO Blood Droplets, Our Life
Organization: GB Patch Games
Tumblr: gb-patch
itch: gbpatch
Contact:

Re: Hiding Menu Options Issue

#7 Post by Googaboga » Sun Jun 22, 2014 7:43 pm

Do any of the flags you set up equal True? Or are they all set to False? In order to define something you set it to False. So unless you make sure to set the menu options as True before the menu comes along the game won't be able to open the menu since it can only open it if one or more of the options are set to True. And I can't see any of the code beyond the menu so I don't know why it skips things not in the menu :'D.
In-Progress:
Floret Bond, XOXO Blood Droplets, Our Life
Released:
A Foretold Affair, My Magical Divorce Bureau, XOXO Droplets, Lake of Voices

FruitSeller
Newbie
Posts: 19
Joined: Sun Jun 22, 2014 2:46 pm
Contact:

Re: Hiding Menu Options Issue

#8 Post by FruitSeller » Mon Jun 23, 2014 9:43 am

Alright, I'll extend up a little bit to show you the rest of the code that may be relevant.

Code: Select all

  "Emilylacee" "May I ask you a question?"
    "Leta" "Sure, go ahead."
    define name_leta = "False"
    define uniform = "False"
    define houses = "False"
    define thats_all = "False" 

    menu:
         "Ask about her name" if name_leta == False: 
               "Emilylacee" "What's with your name?"     
               "Leta" "What do you mean?"
               "Emilylacee" "Well... it's not exactly a foruming username."
               "Leta" "So?"
               "Emilylacee" "I mean, you must have been one of the first um, submissions..."
               "Leta" "I still don't get your point."
               "She's obviously clueless, I can see."
               "Emilylacee" "Nevermind, it's nothing."
               $ name_leta == True
               jump menu1
 
         "Ask about uniforms" if uniform == False:

               "I had been wondering about the uniform issue for a while now." 
               "Emilylacee" "Alright - do we need to wear uniforms?"
               "Leta" "Uniform is manditory. However, males have no uniform and are strictly permitted to wear certain types of clothing - we aren't nessacerily told what exactly - since we're women."
               "Emilylacee" "What? Seriously, they don't wear a uniform but we have to?"
               "Leta" "The dresscode is very strict."
               "Emilylacee" "I guess..." 
               $ uniform == True
               "Leta" "Any more questions, Emilylacee?" 
               jump menu1
         "Ask about houses" if houses == False:
            "I ask about the houses."
            "Emilylacee" "What's with the weird house names? Are we sorted in them for specific reasons?"
            "Leta smirks."
            "Leta" "House 5 is the undecided group - our actions, grades and several other factors decide if we go up or down. Our dorms don't changed if we get removed from our ranking, though."
            "Leta" "The highest you can be in is House 1 - it's pretty much for the most amazing people around."
            "Leta" "...However, there is another group even more prestigious than House 1 - it's shrouded in mystery."
            "Emilylacee" "What do you mean?"
            "Leta" "The name is House L, nobody really knows anything about it."
            "Leta" "Anyway, the lowest house ranking you can get is House 10 - I don't know how the hell you get there, but once you're there, you're expelled."
            "Emilylacee" "Seems fair, I suppose."
            "Leta" "Yes, very fair."
            $ houses == True
            "Leta" "...Any more questions, Emilylacee?"
            jump menu1
                  

         "That's all." if thats_all == False:
            jump d

    
            label d:
                     "Emilylacee" "After I finished asking my questions, the room eased into a silence as I began unpacking my things."
                     "Emilylacee" "Eventually, however, there was a distinct, shy sounding knock on the door."
                     "???" "H-Hello?"
                     "Emilylacee?" "Who's she-"
                     "Leta" "Come in, Starlilynight."
                     "Starlilynight wore a slender figure, her eyes were bright emerald and her face was flushed a strawberry shade - she seemed to really like the color green, as well."
                     "Starlilynight" "Is she..."
                     "Leta" "Yes. This is our room mate, Emilylacee. Emilylacee, this is your room mate, Starlilynight."
                     "I waved. However, I don't think Starlilynight felt the same way."
                     "Starlilynight" "WAHHHHHH!!!!"
                     "She quickly ducked under Leta's bed, Leta expressing a neutral expression as I stare at her."
                     "Emilylacee" "Is... she okay?"
                     "Leta" "Yes. She just gets... frightened of strangers, don't worry, she'll warm up to you in a few minutes."
                     "Emilylacee" "Okay."
                     "A few minutes pass, it's awfully boring - I stare at Leta, she remains expressionless. I can't help but wonder - who is she?"
                     "She's very calm, extremely calm, in fact. I can't help but wonder how she remains such a calm form. I envy that." 
    
        

A little bit of the point after the menu choice and a tiny bit before, I suppose.
;-;
I don't know if this would be helpful but, well, who knows.

User avatar
Dizzydude
Regular
Posts: 58
Joined: Mon May 26, 2014 8:40 pm
Projects: 「To Be Announced」
Location: U.S.A
Contact:

Re: Hiding Menu Options Issue

#9 Post by Dizzydude » Mon Jun 23, 2014 10:35 am

FruitSeller wrote:Alright, I'll extend up a little bit to show you the rest of the code that may be relevant.

Code: Select all

  "Emilylacee" "May I ask you a question?"
    "Leta" "Sure, go ahead."
    define name_leta = "False"
    define uniform = "False"
    define houses = "False"
    define thats_all = "False" 

    menu:
         "Ask about her name" if name_leta == False: 
               "Emilylacee" "What's with your name?"     
               "Leta" "What do you mean?"
               "Emilylacee" "Well... it's not exactly a foruming username."
               "Leta" "So?"
               "Emilylacee" "I mean, you must have been one of the first um, submissions..."
               "Leta" "I still don't get your point."
               "She's obviously clueless, I can see."
               "Emilylacee" "Nevermind, it's nothing."
               $ name_leta == True
               jump menu1
 
         "Ask about uniforms" if uniform == False:

               "I had been wondering about the uniform issue for a while now." 
               "Emilylacee" "Alright - do we need to wear uniforms?"
               "Leta" "Uniform is manditory. However, males have no uniform and are strictly permitted to wear certain types of clothing - we aren't nessacerily told what exactly - since we're women."
               "Emilylacee" "What? Seriously, they don't wear a uniform but we have to?"
               "Leta" "The dresscode is very strict."
               "Emilylacee" "I guess..." 
               $ uniform == True
               "Leta" "Any more questions, Emilylacee?" 
               jump menu1
         "Ask about houses" if houses == False:
            "I ask about the houses."
            "Emilylacee" "What's with the weird house names? Are we sorted in them for specific reasons?"
            "Leta smirks."
            "Leta" "House 5 is the undecided group - our actions, grades and several other factors decide if we go up or down. Our dorms don't changed if we get removed from our ranking, though."
            "Leta" "The highest you can be in is House 1 - it's pretty much for the most amazing people around."
            "Leta" "...However, there is another group even more prestigious than House 1 - it's shrouded in mystery."
            "Emilylacee" "What do you mean?"
            "Leta" "The name is House L, nobody really knows anything about it."
            "Leta" "Anyway, the lowest house ranking you can get is House 10 - I don't know how the hell you get there, but once you're there, you're expelled."
            "Emilylacee" "Seems fair, I suppose."
            "Leta" "Yes, very fair."
            $ houses == True
            "Leta" "...Any more questions, Emilylacee?"
            jump menu1
                  

         "That's all." if thats_all == False:
            jump d

    
            label d:
                     "Emilylacee" "After I finished asking my questions, the room eased into a silence as I began unpacking my things."
                     "Emilylacee" "Eventually, however, there was a distinct, shy sounding knock on the door."
                     "???" "H-Hello?"
                     "Emilylacee?" "Who's she-"
                     "Leta" "Come in, Starlilynight."
                     "Starlilynight wore a slender figure, her eyes were bright emerald and her face was flushed a strawberry shade - she seemed to really like the color green, as well."
                     "Starlilynight" "Is she..."
                     "Leta" "Yes. This is our room mate, Emilylacee. Emilylacee, this is your room mate, Starlilynight."
                     "I waved. However, I don't think Starlilynight felt the same way."
                     "Starlilynight" "WAHHHHHH!!!!"
                     "She quickly ducked under Leta's bed, Leta expressing a neutral expression as I stare at her."
                     "Emilylacee" "Is... she okay?"
                     "Leta" "Yes. She just gets... frightened of strangers, don't worry, she'll warm up to you in a few minutes."
                     "Emilylacee" "Okay."
                     "A few minutes pass, it's awfully boring - I stare at Leta, she remains expressionless. I can't help but wonder - who is she?"
                     "She's very calm, extremely calm, in fact. I can't help but wonder how she remains such a calm form. I envy that." 
    
        

A little bit of the point after the menu choice and a tiny bit before, I suppose.
;-;
I don't know if this would be helpful but, well, who knows.


I think I see it this time.
Wow, I know something.
Hopefully I'm not wrong and I don't look stupid.

Anyway, where you're using "define",

Code: Select all

  "Emilylacee" "May I ask you a question?"
    "Leta" "Sure, go ahead."
    define name_leta = "False"
    define uniform = "False"
    define houses = "False"
    define thats_all = "False" 
The "define" should be a $ sign, telling Ren'Py it's a line of python.
Unless that's another way to do it, at least. That might be the issue.


EDIT: Example-

Code: Select all

  "Emilylacee" "May I ask you a question?"
    "Leta" "Sure, go ahead."
    $ name_leta = "False"
    $ uniform = "False"
    $ houses = "False"
    $ thats_all = "False" 

User avatar
Valmoer
Regular
Posts: 53
Joined: Sat Feb 04, 2012 9:46 pm
Contact:

Re: Hiding Menu Options Issue

#10 Post by Valmoer » Mon Jun 23, 2014 2:55 pm

Warning : wall of text and code incoming :)

Code: Select all

    "Emilylacee" "May I ask you a question?"
    "Leta" "Sure, go ahead."
    define name_leta = "False"
    define uniform = "False"
    define houses = "False"
    define thats_all = "False"
You've got two things wrong in that set-up phase:
  • As the Renp'y documentation states, define is indeed a way to set a variable up, but only at initialization time (as if you used the init statement). Dizzydude is correct to suggest substituting the define statement with the $ shorthand (though you could use the python statement, as well)
  • Nonetheless, you are also wrong with the content you set up your variable with. You're setting them up with "False", which is a character string containing the characters F, a, l, s & e, which you then compare to the Boolean constant False, which is an abstract Boolean value (roughly "equal" to 0, to the empty string and a few other "empty" values 1).
    Therefore, when you reach the comparison "Ask about her name" if name_leta == False: you're comparing name_leta a variable which contains "False", a non-empty character string (thus equivalent to the Boolean constant True) to the Boolean constant False. You have a True == False comparison, for all of the comparisons tests, and thus no menu option is selectable.
1 If you're curious about what values evaluates to which kind of Boolean result, you can find relevant info in the official python documentation

Also you've make the reverse mistake of the one you made in your previous thread :

Code: Select all

    $ uniform == True
    "Leta" "Any more questions, Emilylacee?"
    jump menu1
You wanted to set the uniform variable to True, but while you should have used =, the assignation operator (x = a <=>Set x to a) you have instead used ==, the comparison operator (a == b <=>Is a equal to b). Therefore, that line of code evaluated the result of uniform / True comparison, but didn't modify uniform's value as you most probably wished.
The correct code would be

Code: Select all

    $ uniform = True
-----

Now, if I may push my critique of your code a bit further (all in good faith and good fun - I must admit I'm intrigued by the snippet of world-building we can see in that scene, so I'd like to see you succeed :) ), I'm afraid some of your code design decisions are inelegant : it can clutter the code to put a scene's content inside the menu option, if there's more than a couple of lines. Cluttering the code can make it harder to debug, especially if the code is to be handled and debugged by someone who isn't its original developer (or by its original developer, but three months after coding it :lol:) Here for example, you cannot tell at a glance that there are four choices, three being conditioned by a variable.

Now, the most efficient way I've found to build both beautiful and efficient code is to build it as blocks within blocks within blocks.
For example, the basic pattern of a branching menu follows that pattern :
Set-Up Phase
Menu
Scene Contents
Expanding a bit, we precise the menu and content blocks with their individual elements :
Set-Up Phase
Menu
  • Choice 1
  • Choice 2
  • Choice 3


Scene Contents
  • Choice 1
  • Choice 2
  • Choice 3

Expanding further, we define the building blocks of each choice and/or scene snippets,
Set-Up Phase
Menu
  • Choice 1
    • Choice text
    • Condition on the variable
    • Jump to Relevant content
  • Choice 2
  • Choice 3
Scene Contents
  • Choice 1's scene
    • Named label statement
    • Scene (text, images, transitions,... the works)
    • Flagging the variable up with True
    • Jump back to the menu
  • Choice 2
  • Choice 3
Translating back into (something resembling your) code, that gives:

Code: Select all

#Setup zone
python:
    name_leta_asked = False
    uniform_asked = False
    houses_asked = False
#End of setup zone

#Menu zone
"Emilylacee" "May I ask you a question?"
"Leta" "Sure, go ahead."
menu menu1:
    "Ask about her name" if name_leta_asked == False:
        jump name_leta

    "Ask about uniforms" if uniform_asked == False:
        jump uniform

    "Ask about houses" if houses_asked == False:
        jump houses

    "That's all.":
        jump end_of_discussion

#End of menu zone

#Scene content zone
label name_leta:
    "Emilylacee" "What's with your name?"     
    "Leta" "What do you mean?"
    "Emilylacee" "Well... it's not exactly a foruming username."
    "Leta" "So?"
    "Emilylacee" "I mean, you must have been one of the first um, submissions..."
    "Leta" "I still don't get your point."
    "She's obviously clueless, I can see."
    "Emilylacee" "Nevermind, it's nothing."

    $ name_leta_asked = True
    jump menu1


label houses:
    "I ask about the houses."
    "Emilylacee" "What's with the weird house names? Are we sorted in them for specific reasons?"
    "Leta smirks."
    "Leta" "House 5 is the undecided group - our actions, grades and several other factors decide if we go up or down. Our dorms don't changed if we get removed from our ranking, though."
    "Leta" "The highest you can be in is House 1 - it's pretty much for the most amazing people around."
    "Leta" "...However, there is another group even more prestigious than House 1 - it's shrouded in mystery."
    "Emilylacee" "What do you mean?"
    "Leta" "The name is House L, nobody really knows anything about it."
    "Leta" "Anyway, the lowest house ranking you can get is House 10 - I don't know how the hell you get there, but once you're there, you're expelled."
    "Emilylacee" "Seems fair, I suppose."
    "Leta" "Yes, very fair."
    "Leta" "...Any more questions, Emilylacee?"

    $ houses_asked = True
    jump menu1

label uniform:
    "I had been wondering about the uniform issue for a while now."
    "Emilylacee" "Alright - do we need to wear uniforms?"
    "Leta" "Uniform is manditory. However, males have no uniform and are strictly permitted to wear certain types of clothing - we aren't nessacerily told what exactly - since we're women."
    "Emilylacee" "What? Seriously, they don't wear a uniform but we have to?"
    "Leta" "The dresscode is very strict."
    "Emilylacee" "I guess..."
    "Leta" "Any more questions, Emilylacee?"

    $ uniform_asked = True
    jump menu1

#End of branching content

label end_of_discussion:
    "Emilylacee" "After I finished asking my questions, the room eased into a silence as I began unpacking my things."
    "Emilylacee" "Eventually, however, there was a distinct, shy sounding knock on the door."
    "???" "H-Hello?"
    "Emilylacee?" "Who's she-"
    "Leta" "Come in, Starlilynight."
    "Starlilynight wore a slender figure, her eyes were bright emerald and her face was flushed a strawberry shade - she seemed to really like the color green, as well."
    "Starlilynight" "Is she..."
    "Leta" "Yes. This is our room mate, Emilylacee. Emilylacee, this is your room mate, Starlilynight."
    "I waved. However, I don't think Starlilynight felt the same way."
    "Starlilynight" "WAHHHHHH!!!!"
    "She quickly ducked under Leta's bed, Leta expressing a neutral expression as I stare at her."
    "Emilylacee" "Is... she okay?"
    "Leta" "Yes. She just gets... frightened of strangers, don't worry, she'll warm up to you in a few minutes."
    "Emilylacee" "Okay."
    "A few minutes pass, it's awfully boring - I stare at Leta, she remains expressionless. I can't help but wonder - who is she?"
    "She's very calm, extremely calm, in fact. I can't help but wonder how she remains such a calm form. I envy that."
#End of content zone

return
Now, with the code formatted this way,

Code: Select all

#Menu zone
[... ...]
menu menu1:
    "Ask about her name" if name_leta_asked == False:
        jump name_leta

    "Ask about uniforms" if uniform_asked == False:
        jump uniform

    "Ask about houses" if houses_asked == False:
        jump houses

    "That's all.":
        jump end_of_discussion

#End of menu zone
you can see the menu as it will appear in Ren'py more clearly than if the various scenes' content would have separated the options.

Coding is sometimes nebulous for newcomers, but don't lose hope - practice make perfect :D (well, that and the helpful advice of this forum :lol:).

FruitSeller
Newbie
Posts: 19
Joined: Sun Jun 22, 2014 2:46 pm
Contact:

Re: Hiding Menu Options Issue

#11 Post by FruitSeller » Mon Jun 23, 2014 9:23 pm

Valmoer wrote:Warning : wall of text and code incoming :)

Code: Select all

    "Emilylacee" "May I ask you a question?"
    "Leta" "Sure, go ahead."
    define name_leta = "False"
    define uniform = "False"
    define houses = "False"
    define thats_all = "False"
You've got two things wrong in that set-up phase:
  • As the Renp'y documentation states, define is indeed a way to set a variable up, but only at initialization time (as if you used the init statement). Dizzydude is correct to suggest substituting the define statement with the $ shorthand (though you could use the python statement, as well)
  • Nonetheless, you are also wrong with the content you set up your variable with. You're setting them up with "False", which is a character string containing the characters F, a, l, s & e, which you then compare to the Boolean constant False, which is an abstract Boolean value (roughly "equal" to 0, to the empty string and a few other "empty" values 1).
    Therefore, when you reach the comparison "Ask about her name" if name_leta == False: you're comparing name_leta a variable which contains "False", a non-empty character string (thus equivalent to the Boolean constant True) to the Boolean constant False. You have a True == False comparison, for all of the comparisons tests, and thus no menu option is selectable.
1 If you're curious about what values evaluates to which kind of Boolean result, you can find relevant info in the official python documentation

Also you've make the reverse mistake of the one you made in your previous thread :

Code: Select all

    $ uniform == True
    "Leta" "Any more questions, Emilylacee?"
    jump menu1
You wanted to set the uniform variable to True, but while you should have used =, the assignation operator (x = a <=>Set x to a) you have instead used ==, the comparison operator (a == b <=>Is a equal to b). Therefore, that line of code evaluated the result of uniform / True comparison, but didn't modify uniform's value as you most probably wished.
The correct code would be

Code: Select all

    $ uniform = True
-----

Now, if I may push my critique of your code a bit further (all in good faith and good fun - I must admit I'm intrigued by the snippet of world-building we can see in that scene, so I'd like to see you succeed :) ), I'm afraid some of your code design decisions are inelegant : it can clutter the code to put a scene's content inside the menu option, if there's more than a couple of lines. Cluttering the code can make it harder to debug, especially if the code is to be handled and debugged by someone who isn't its original developer (or by its original developer, but three months after coding it :lol:) Here for example, you cannot tell at a glance that there are four choices, three being conditioned by a variable.

Now, the most efficient way I've found to build both beautiful and efficient code is to build it as blocks within blocks within blocks.
For example, the basic pattern of a branching menu follows that pattern :
Set-Up Phase
Menu
Scene Contents
Expanding a bit, we precise the menu and content blocks with their individual elements :
Set-Up Phase
Menu
  • Choice 1
  • Choice 2
  • Choice 3


Scene Contents
  • Choice 1
  • Choice 2
  • Choice 3

Expanding further, we define the building blocks of each choice and/or scene snippets,
Set-Up Phase
Menu
  • Choice 1
    • Choice text
    • Condition on the variable
    • Jump to Relevant content
  • Choice 2
  • Choice 3
Scene Contents
  • Choice 1's scene
    • Named label statement
    • Scene (text, images, transitions,... the works)
    • Flagging the variable up with True
    • Jump back to the menu
  • Choice 2
  • Choice 3
Translating back into (something resembling your) code, that gives:

Code: Select all

#Setup zone
python:
    name_leta_asked = False
    uniform_asked = False
    houses_asked = False
#End of setup zone

#Menu zone
"Emilylacee" "May I ask you a question?"
"Leta" "Sure, go ahead."
menu menu1:
    "Ask about her name" if name_leta_asked == False:
        jump name_leta

    "Ask about uniforms" if uniform_asked == False:
        jump uniform

    "Ask about houses" if houses_asked == False:
        jump houses

    "That's all.":
        jump end_of_discussion

#End of menu zone

#Scene content zone
label name_leta:
    "Emilylacee" "What's with your name?"     
    "Leta" "What do you mean?"
    "Emilylacee" "Well... it's not exactly a foruming username."
    "Leta" "So?"
    "Emilylacee" "I mean, you must have been one of the first um, submissions..."
    "Leta" "I still don't get your point."
    "She's obviously clueless, I can see."
    "Emilylacee" "Nevermind, it's nothing."

    $ name_leta_asked = True
    jump menu1


label houses:
    "I ask about the houses."
    "Emilylacee" "What's with the weird house names? Are we sorted in them for specific reasons?"
    "Leta smirks."
    "Leta" "House 5 is the undecided group - our actions, grades and several other factors decide if we go up or down. Our dorms don't changed if we get removed from our ranking, though."
    "Leta" "The highest you can be in is House 1 - it's pretty much for the most amazing people around."
    "Leta" "...However, there is another group even more prestigious than House 1 - it's shrouded in mystery."
    "Emilylacee" "What do you mean?"
    "Leta" "The name is House L, nobody really knows anything about it."
    "Leta" "Anyway, the lowest house ranking you can get is House 10 - I don't know how the hell you get there, but once you're there, you're expelled."
    "Emilylacee" "Seems fair, I suppose."
    "Leta" "Yes, very fair."
    "Leta" "...Any more questions, Emilylacee?"

    $ houses_asked = True
    jump menu1

label uniform:
    "I had been wondering about the uniform issue for a while now."
    "Emilylacee" "Alright - do we need to wear uniforms?"
    "Leta" "Uniform is manditory. However, males have no uniform and are strictly permitted to wear certain types of clothing - we aren't nessacerily told what exactly - since we're women."
    "Emilylacee" "What? Seriously, they don't wear a uniform but we have to?"
    "Leta" "The dresscode is very strict."
    "Emilylacee" "I guess..."
    "Leta" "Any more questions, Emilylacee?"

    $ uniform_asked = True
    jump menu1

#End of branching content

label end_of_discussion:
    "Emilylacee" "After I finished asking my questions, the room eased into a silence as I began unpacking my things."
    "Emilylacee" "Eventually, however, there was a distinct, shy sounding knock on the door."
    "???" "H-Hello?"
    "Emilylacee?" "Who's she-"
    "Leta" "Come in, Starlilynight."
    "Starlilynight wore a slender figure, her eyes were bright emerald and her face was flushed a strawberry shade - she seemed to really like the color green, as well."
    "Starlilynight" "Is she..."
    "Leta" "Yes. This is our room mate, Emilylacee. Emilylacee, this is your room mate, Starlilynight."
    "I waved. However, I don't think Starlilynight felt the same way."
    "Starlilynight" "WAHHHHHH!!!!"
    "She quickly ducked under Leta's bed, Leta expressing a neutral expression as I stare at her."
    "Emilylacee" "Is... she okay?"
    "Leta" "Yes. She just gets... frightened of strangers, don't worry, she'll warm up to you in a few minutes."
    "Emilylacee" "Okay."
    "A few minutes pass, it's awfully boring - I stare at Leta, she remains expressionless. I can't help but wonder - who is she?"
    "She's very calm, extremely calm, in fact. I can't help but wonder how she remains such a calm form. I envy that."
#End of content zone

return
Now, with the code formatted this way,

Code: Select all

#Menu zone
[... ...]
menu menu1:
    "Ask about her name" if name_leta_asked == False:
        jump name_leta

    "Ask about uniforms" if uniform_asked == False:
        jump uniform

    "Ask about houses" if houses_asked == False:
        jump houses

    "That's all.":
        jump end_of_discussion

#End of menu zone
you can see the menu as it will appear in Ren'py more clearly than if the various scenes' content would have separated the options.

Coding is sometimes nebulous for newcomers, but don't lose hope - practice make perfect :D (well, that and the helpful advice of this forum :lol:).
:O Thank you! I didn't think somebody would put such effort to help! It's unfortunate that my keyboard must break right when I see such helpful advice. (Onscreen keyboard is a horrible thing ;-;) But seriously , thank you! I'll try to do as you've told when I get a working keyboard c:

Post Reply

Who is online

Users browsing this forum: Bing [Bot], gas, Majestic-12 [Bot], RicharDann