[Solved] Context sensitive 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
pod7
Newbie
Posts: 7
Joined: Thu May 23, 2013 3:58 pm
Contact:

[Solved] Context sensitive choices?

#1 Post by pod7 » Mon Oct 10, 2016 1:53 pm

First of all, sorry if that's not the right term for what I'm asking for. I've poured over the old wiki and looked through the forums and couldn't find the answer I was looking for (though I did try various things) so now I'm here.

Basically what I want to do is to make a menu choice pop up in a menu but ONLY if the player chose specific answers in previous questions. So like:

"Do you like pizza?":
-"Yes"
-"No"
-if all the player has chosen to eat by this point is Pizza "It's the only thing I eat actually"

I tried flagging each relevant choice as an if statement and then chaining them back to back, and that didn't work, and then I tried the point system, but that didn't work either (kept getting 'expected menuitem' but I have everything indented the way it should be) so now I'm stumped.
Last edited by pod7 on Mon Oct 10, 2016 3:06 pm, edited 1 time in total.

User avatar
Ocelot
Eileen-Class Veteran
Posts: 1883
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: Context sensitive choices?

#2 Post by Ocelot » Mon Oct 10, 2016 2:15 pm

Something like:

Code: Select all

"Do you like pizza?"
menu:
    'yes':
        pass
    'no':
        pass
    "It's the only thing I eat actually" if likes_pizza > 5:
        pass
< < insert Rick Cook quote here > >

User avatar
trooper6
Lemma-Class Veteran
Posts: 3712
Joined: Sat Jul 09, 2011 10:33 pm
Projects: A Close Shave
Location: Medford, MA
Contact:

Re: Context sensitive choices?

#3 Post by trooper6 » Mon Oct 10, 2016 2:22 pm

First off, don't read the old wiki. It is very out of date. Look at conditional statements for menus, which is documented in the current documentation here:
https://www.renpy.org/doc/html/menus.html

Secondly, there are alway many roads to Rome. So there is more that one way to do what you want. You could do it how ocelot did it you can do it like this:

Code: Select all

default  only_pizza = True

label start:
    menu:
        "What will you eat?"
        "Salad":
            $only_pizza = False
            "The salad is tasty!"
        "Pizza":
            "Yummy! Pizza!"

    "Game continues..."

    menu:
        "Do you like pizza?"
        "Yes.":
            "Me too!"
        "No.":
            "Pizza is the worst!"
        "It's the only thing I eat actually" if only_pizza:
            "I see, then you win the secret prize!" 
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)
Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978

pod7
Newbie
Posts: 7
Joined: Thu May 23, 2013 3:58 pm
Contact:

Re: Context sensitive choices?

#4 Post by pod7 » Mon Oct 10, 2016 3:05 pm

@trooper6 Thanks, that worked perfectly! Sorry it took so long to reply, had a lot of indenting to do! I feel like I learn something new every day making this VN, it's the most fun I've had in a long time, so thanks for facilitating that :D

Post Reply

Who is online

Users browsing this forum: No registered users