How to avoid menus being disrupted by screens

A place for Ren'Py tutorials and reusable Ren'Py code.
Forum rules
Do not post questions here!

This forum is for example code you want to show other people. Ren'Py questions should be asked in the Ren'Py Questions and Announcements forum.
Post Reply
Message
Author
RewindTheGame
Regular
Posts: 94
Joined: Thu Dec 31, 2020 3:37 pm
Contact:

How to avoid menus being disrupted by screens

#1 Post by RewindTheGame »

Sorry for the title, but I don't know how else to put this. If a moderator can think of a better title, please feel free to change it to something that actually makes sense!

Anyway, I've seen it noted on here before that calling up a screen (such as an inventory) when a menu is displayed can cause undesirable effects when the screen closes, and although various suggestions have been made as to how to mitigate this, nothing has ever really worked for me and I've always ended up having to remove the button that calls up the screen whenever a menu is displayed. This hasn't been ideal.

Anyway, I've just come up with a solution which works well. All you need to do is add an extra item to the end of each of your menus, but use a variable to make sure it never gets displayed. Then. make that menu item simply loop around to display the menu again. What seems to happen when the player calls up a screen and then returns to the menu is that, for whatever mysterious internal RenPy reason, the last option on the menu gets run whether it's visible or not. So:

Code: Select all

label my_menu:
	$bugfixone=False
	menu:
		"First item":
			jump somelabel
		"Second item":
			jump somelabel2
		"Third item":
			jump somelabel3
		"..." if bugfixone==True:
			jump my_menu
Now, if the player does something to display a screen while this menu is displayed and then exits the screen, RenPy runs the code following the last item on the menu - even though that menu item isn't supposed to be available. This then just redisplays the menu.
Last edited by RewindTheGame on Wed Jul 10, 2024 10:04 am, edited 1 time in total.

giorgi1111
Regular
Posts: 163
Joined: Sat May 04, 2024 10:40 pm
Contact:

Re: How to avoid menus being disrupted by screens

#2 Post by giorgi1111 »

are you calling that menu label in other label? why you need that? you can name menu for example menu sonething: menu items and when you need that menu jump("sonething") also you can use screens as menus with inagebuttons or textbuttons

RewindTheGame
Regular
Posts: 94
Joined: Thu Dec 31, 2020 3:37 pm
Contact:

Re: How to avoid menus being disrupted by screens

#3 Post by RewindTheGame »

giorgi1111 wrote: Mon Jul 01, 2024 12:50 pm are you calling that menu label in other label? why you need that? you can name menu for example menu sonething: menu items and when you need that menu jump("sonething") also you can use screens as menus with inagebuttons or textbuttons
I don't understand what you were trying to say here, sorry :(

As far as I'm aware, this is just how you make menus in RenPy. It's how I see menus written in every RenPy program I've seen, and it's how menus are described in the documentation here: https://www.renpy.org/doc/html/menus.html.

I think you may have misunderstood the purpose of this code. Obviously, if you've made your own menu screen then you don't need the built in one - but this is a solve for a problem with the basic RenPy menu system.

giorgi1111
Regular
Posts: 163
Joined: Sat May 04, 2024 10:40 pm
Contact:

Re: How to avoid menus being disrupted by screens

#4 Post by giorgi1111 »

what is other code? why is there menu when you showing screen? as renpy is for visual novels that menu is made for it. you can make menus and other things.
show one label where you using that menu and one screen to see how closing screen and jumping menu
i am creating game where i have screen topbar for imagebuttons as menu and each imagebutton using as drop down menu and they are screens too .

RewindTheGame
Regular
Posts: 94
Joined: Thu Dec 31, 2020 3:37 pm
Contact:

Re: How to avoid menus being disrupted by screens

#5 Post by RewindTheGame »

giorgi1111 wrote: Mon Jul 01, 2024 3:26 pm what is other code? why is there menu when you showing screen? as renpy is for visual novels that menu is made for it. you can make menus and other things.
show one label where you using that menu and one screen to see how closing screen and jumping menu
i am creating game where i have screen topbar for imagebuttons as menu and each imagebutton using as drop down menu and they are screens too .
Okay. I have an RPG with an inventory system. The button to display the inventory is always on screen. When you press the inventory button, it displays an inventory screen over the top of everything else, modally. When the player presses the EXIT button within the inventory screen, the screen is removed from the screen and they return to whatever they were previously doing in the game.

IF there is a menu displayed when they press the inventory button, then obviously you expect the game to return to the same point when you leave the inventory - IE: you want the menu to still be displayed. This does not happen, and is a known issue discussed elsewhere on these forums. Instead of returning to the menu, the game jumps to the first line of the final item on the menu, which may be something you don't want the player to see or which breaks the game. This is a bug. The only other way to avoid this situation is to physically remove the button that shows the inventory whenever a menu is on the screen so that the player cannot press it - but that's not ideal in a game where a menu is displayed regularly.

Again, this has been discussed elsewhere and I am not the only person to have mentioned it. I simply point out that adding a non-visible item to the end of the menu which isn't displayed means that the menu can loop around in this situation and display correctly.

JonathanHansen
Newbie
Posts: 1
Joined: Fri Jun 28, 2024 7:59 am
Contact:

Re: How to avoid menus being disrupted by screens

#6 Post by JonathanHansen »

Adding an invisible menu item that loops back to display the menu again is a smart workaround. It prevents unintended actions after closing screens, ensuring smoother navigation without removing necessary buttons. My experience with https://domypaper.com/ was excellent. The writer delivered a well-researched and well-written paper, that met all my requirements. The customer support was very responsive and helpful throughout the process. I am very satisfied with the service and would recommend it to anyone needing academic assistance.
Last edited by JonathanHansen on Fri Jul 19, 2024 5:30 am, edited 1 time in total.

RewindTheGame
Regular
Posts: 94
Joined: Thu Dec 31, 2020 3:37 pm
Contact:

Re: How to avoid menus being disrupted by screens

#7 Post by RewindTheGame »

JonathanHansen wrote: Wed Jul 10, 2024 1:18 am Thank you so much for the solution.
No problem, I just wish I could've thought of a better title :)

I've also just fixed the code in the example to correct a spelling error - it should've been bugfixone and not bigfixone on the first line.

Post Reply

Who is online

Users browsing this forum: No registered users