Page 1 of 1

Questions on choices and menues

Posted: Mon Apr 14, 2008 2:54 pm
by Yonorang
Hello everyone!
I'm still pretty new to Ren'Py and trying to figure out how
how to getting it to do, what I want to do. German being
the only language I can use fluently is another thing, but
that is a whole different matter ^^;.

As for what this topic is about:
Currently I'm trying too script various kind of menues that
are interdependent and that are affected by choices earlier
made in the game.
For example let's say that there are two options, no.1 being
that I attend the P.E. lesson and no.2 that I play the piano
instead. The second menu contains 3 options, one being
that I take a shower.
How do I hide this option, if I did not take option no.1 in
the first menu?

On the game I'm planning to do:
The protagonist of this game is a psychometre, who is able
to obtain information on an object and anything that was
in contact with it by meerly touching it. Depending on the
player's choice the protagonist is drawn into an adventure,
which will not only unveil the mysteries of the past but also
influence his surroundings.

Re: Questions on choices and menues

Posted: Mon Apr 14, 2008 3:02 pm
by PyTom
Menus choices support an if clause that can be used to check a flag. For example, you could have the found_hidden_room flag, and then check it like:

Code: Select all

menu:
    "Where should I go?"
    "Bedroom":
         jump bedroom
    "Bathroom":
         jump bathroom
    "Hidden room" if found_hidden_room:
         jump hidden_room

Re: Questions on choices and menues

Posted: Mon Apr 14, 2008 3:08 pm
by Yonorang
Thanks for the fast reply!
And what do I have to do if I want to hide
the "Hidden room"-option, when the prota-
gonist has not found that room, yet?

Re: Questions on choices and menues

Posted: Mon Apr 14, 2008 5:26 pm
by rioka
You don't have to do anything. Just as long as the protagonist hasn't found the hidden room, the player won't see that option. It will only appear when it is found because that if clause is basically saying, "show this option only if the hidden room as been found". If it hasn't been found, it won't show up.

Re: Questions on choices and menues

Posted: Mon Apr 14, 2008 7:54 pm
by Deji
I have a related question!
I've serached around, but i'm not sure about how to do this...

I have a menu with several questions you can ask a character

Code: Select all

menu:
    "question1?":
        #ask question1
    "question2?":
        #ask question2
    "question3?":
        #ask question3
    "question4?":
        #ask question4
Now, what I want to do is that after asking the question and getting the responses, the menu is displayed again, but without the question you already asked.

so after you ask , say, question2,
your choices are
question1
question3
question4

How do I do this? ^^;

Re: Questions on choices and menues

Posted: Mon Apr 14, 2008 8:11 pm
by Jake
Deji wrote: Now, what I want to do is that after asking the question and getting the responses, the menu is displayed again, but without the question you already asked.
[...]
How do I do this? ^^;
Set up some variables which hold true/false values depending on whether or not a particular question has been asked yet or not. It's probably best to set them all to false just before the menu if you're going to re-use the same ones throughout.

Then, just do the same if trick as above, for each question, and in label for each question set the variable for that question to 'true', e.g.

Code: Select all

$ q1asked = False
$ q2asked = False
$ q3asked = False
$ q4asked = False

menu:
    "question1?" if q1asked == False:
        jump q1
    "question2?" if q2asked == False:
        [...]

q1:
    $ q1asked = True
    [...]

Re: Questions on choices and menues

Posted: Mon Apr 14, 2008 8:35 pm
by Deji
Thanks a lot =D!
in the end I made it like this:

Code: Select all

$ qmade = 0
$ q1asked = False
$ q2asked = False
$ q3asked = False
$ q4asked = False

label many_questions:
menu:
    "question1?" if q1asked == False:
        $ qmade +=1
        jump q1
    "question2?" if q2asked == False:
        [...]

q1:
    $ q1asked = True
    #lalala
    if qmade > 3:
         jump end_of_questions
    else:
         jump many_questions

    [...]

Re: Questions on choices and menues

Posted: Tue Apr 15, 2008 4:46 am
by monele
Wasn't there a way to do that by providing an empty list that would fill automatically as you picked choices? I can't find it on the wiki o_O;...

Re: Questions on choices and menues

Posted: Wed Apr 16, 2008 7:16 am
by chronoluminaire
Yes, Elven Relations used this option. It doesn't appear to be documented on the The Ren'Py Language reference page, or anywhere else on the wiki.

The way to do it is to add a line saying "set variable_name" into your menu statement. You need to define the variable variable_name to be equal to [] before the menu happens. The code can look like this: (note the line "set talk_set" just after the "menu:" line)

Code: Select all

  $ talk_set = []
  jump talk_menu

label talk_menu:
  menu:
    set talk_set
    "Talk to A":
      jump A
    "Talk to B":
      jump B
    "Talk to C":
      jump C
  "That's all the talking for today."
  jump done

label A:
  "I have a conversation with A."
  jump talk_menu
label B:
  "I have a conversation with B."
  jump talk_menu
label C:
  "I have a conversation with C."
  jump talk_menu
label done:
  $ renpy.full_restart()
Of course, Deji's way still works, and although it's more code, it's also more flexible. There's nothing saying you have to use the set parameter; it just makes it simpler to do what you're after, if that's all you need.

Re: Questions on choices and menues

Posted: Thu Apr 17, 2008 8:19 pm
by Deji
yay! thanks chronoluminaire =D
I think I'll end up using a combination of both, because I still need the counter for the questions asked for something else =3