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
User avatar
TheOneAndOnly-K
Regular
Posts: 78
Joined: Mon Apr 07, 2014 10:33 am
Contact:

Menu Choices

#1 Post by TheOneAndOnly-K »

Okay, I want to do two things with menu choices...

1. To move the menu choices up, so they're not running over my text box.
2. To make certain choices available if a path/gift is unlocked.

Eg: I have asked player to decide whether they wish to join school council or not. If they agree, I'd like to open a new option in the morning for them to 'visit the office', but not skip the time period doing so.

User avatar
TheOneAndOnly-K
Regular
Posts: 78
Joined: Mon Apr 07, 2014 10:33 am
Contact:

Re: Menu Choices

#2 Post by TheOneAndOnly-K »

Bump...

User avatar
Showsni
Miko-Class Veteran
Posts: 563
Joined: Tue Jul 24, 2007 12:58 pm
Contact:

Re: Menu Choices

#3 Post by Showsni »

To make a conditional menu choice, just use if. Let's say that earlier in the game players could choose to learn Spanish, which set a variable $ Spanish = True (and if they chose not to it's set to $ Spanish = False). Then your menu could read:

Code: Select all

"What shall I do today?"
menu:
    "Go shopping":
        ...
    "Stay at home":
        ...
    "Go to Spain" if Spanish:
        ...
Then the last option will only show up in the menu is Spanish is True.

User avatar
TheOneAndOnly-K
Regular
Posts: 78
Joined: Mon Apr 07, 2014 10:33 am
Contact:

Re: Menu Choices

#4 Post by TheOneAndOnly-K »

That's why it's not working.. I put the coding in backwards XD Thanks a lot~

User avatar
Alex
Lemma-Class Veteran
Posts: 3094
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: Menu Choices

#5 Post by Alex »

1. In screens.rpy

Code: Select all

screen choice:

    window: 
        style "menu_window"        
        xalign 0.5
        yalign 0.5      #<=== set it to 0.3 or so to move choice menu up (rest of the code unchanged)

User avatar
TheOneAndOnly-K
Regular
Posts: 78
Joined: Mon Apr 07, 2014 10:33 am
Contact:

Re: Menu Choices

#6 Post by TheOneAndOnly-K »

It works, but perhaps there's a way it wont cut into the text box...?

User avatar
TheOneAndOnly-K
Regular
Posts: 78
Joined: Mon Apr 07, 2014 10:33 am
Contact:

Re: Menu Choices

#7 Post by TheOneAndOnly-K »

Another question:

How would I write it if, as above it was

Code: Select all

menu:
       "Yadda" if ? == True:
but with two ?'s needed to be on.

User avatar
Alex
Lemma-Class Veteran
Posts: 3094
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: Menu Choices

#8 Post by Alex »

You can use boolean operations - https://docs.python.org/3/library/stdtypes.html

Code: Select all

menu:
       "Yadda" if var1 == True and var2 >= 5:
As for positioning choice menu, it's all up to you how to "design" it - if you really want to show 10 or more choices you could make a two-column choice menu or put it inside a viewport to let player scroll through it.
http://lemmasoft.renai.us/forums/viewto ... =8&t=16914
http://www.renpy.org/doc/html/screens.html#viewport

User avatar
TheOneAndOnly-K
Regular
Posts: 78
Joined: Mon Apr 07, 2014 10:33 am
Contact:

Re: Menu Choices

#9 Post by TheOneAndOnly-K »

Thank you!~

User avatar
TheOneAndOnly-K
Regular
Posts: 78
Joined: Mon Apr 07, 2014 10:33 am
Contact:

Re: Menu Choices

#10 Post by TheOneAndOnly-K »

Bump!

Question: If I have an 'if' command I want to run first, how do I make it run without turning the other commands off?

User avatar
Alex
Lemma-Class Veteran
Posts: 3094
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: Menu Choices

#11 Post by Alex »

It works like:
- do one of possible stuffs

Code: Select all

if var == value:
    do stuff
else:
    do other stuff
or

Code: Select all

if var == value:
    do stuff
elif var == value_2:
    do stuff_2
else:
    do other stuff
- or do each of stuffs if appropriate condition is true

Code: Select all

if var_1 == value_1:
    do stuff_1
if var_2 == value_2:
    do stuff_2
if var_3 == value_3:
    do stuff_3
http://www.renpy.org/doc/html/conditional.html

Post Reply

Who is online

Users browsing this forum: Google [Bot]