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
-----
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
) 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
Scene Contents
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
(well, that and the helpful advice of this forum
).