Ren'Py Blocking player's click on the same menu if he is inside it

3DeadAngel

Newbie
Game Developer
May 10, 2023
43
48
Hello! I'm pretty sure that there is a prettier solution rather than making hundreds of menus where I always exclude the menu where is he in.

My idea with basic code would be:

menu xxxx:
"xxx":
blabla
jump xxxx
"xx":
bla
jump xxxx
"x": <- player currently here and he shouldnt be able to choose this menu again, keep in mind that he should have the ability to click it again once he went into a different menu point
bla
jump xxxx

I know that I could use flags and set it true once he clicked a point but then the player wouldn't be able to visit the menu point again.
 

79flavors

Well-Known Member
Respected User
Jun 14, 2018
1,576
2,203
What you are asking could be done by tracking which room you are in using a variable.
There are better ways to do this than this solution. But since you are trying to get a menu: working like this, I think this is good enough for the moment.

You can change which menu items appear by using the if parameter. See .

It is good practice to use lowercase values (actually lowercase everywhere in RenPy will help you, but that's a longer topic). Since "Bedroom" and "bedroom" are two difference values, by only using "bedroom" or other lowercase values, you never have to worry you've mistyped it.

Python:
label start:

    $ this_location = "nowhere"


label pick_a_room:

    scene black with fade

    menu:
        "Where next?"
        "Bedroom" if this_location != "bedroom":
            jump room_bedroom
        "Kitchen" if this_location != "kitchen":
            jump room_kitchen
        "Garage" if this_location != "garage":
            jump room_garage
        "Exit":
            jump the_end

label room_bedroom:

    $ this_location = "bedroom"
    "You are in the bedroom"

    jump pick_a_room


label room_kitchen:

    $ this_location = "kitchen"
    "You are in the kitchen"

    jump pick_a_room


label room_garage:

    $ this_location = "garage"
    "You are in the garage"

    jump pick_a_room
 

3DeadAngel

Newbie
Game Developer
May 10, 2023
43
48
What you are asking could be done by tracking which room you are in using a variable.
There are better ways to do this than this solution. But since you are trying to get a menu: working like this, I think this is good enough for the moment.

You can change which menu items appear by using the if parameter. See .

It is good practice to use lowercase values (actually lowercase everywhere in RenPy will help you, but that's a longer topic). Since "Bedroom" and "bedroom" are two difference values, by only using "bedroom" or other lowercase values, you never have to worry you've mistyped it.

Python:
label start:

    $ this_location = "nowhere"


label pick_a_room:

    scene black with fade

    menu:
        "Where next?"
        "Bedroom" if this_location != "bedroom":
            jump room_bedroom
        "Kitchen" if this_location != "kitchen":
            jump room_kitchen
        "Garage" if this_location != "garage":
            jump room_garage
        "Exit":
            jump the_end

label room_bedroom:

    $ this_location = "bedroom"
    "You are in the bedroom"

    jump pick_a_room


label room_kitchen:

    $ this_location = "kitchen"
    "You are in the kitchen"

    jump pick_a_room


label room_garage:

    $ this_location = "garage"
    "You are in the garage"

    jump pick_a_room
Wow you're amazing thank you soo much! This is exactly what I was looking for.
 

Turning Tricks

Rendering Fantasies
Game Developer
Apr 9, 2022
946
2,023
I only just discovered using conditionals with a menu myself, less than a month ago. I never had to do a dynamic menu before.

The more I learn about Ren'py, the more I love it.
 

79flavors

Well-Known Member
Respected User
Jun 14, 2018
1,576
2,203