Easy guide to: Pause menu

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
User avatar
Greeny
Miko-Class Veteran
Posts: 921
Joined: Sun Dec 20, 2009 10:15 am
Completed: The Loop, The Madness
Projects: In Orbit, TBA
Organization: Gliese Productions
Location: Cantankerous Castle
Contact:

Easy guide to: Pause menu

#1 Post by Greeny » Sat Jul 20, 2013 7:46 am

As it stands, the default action for pressing ESC or right-clicking is to take you immediately to the save screen.
Here's a quick guide to making a custom pause screen appear, from where players can choose to proceed to save, load preferences, and any other screen you want them to access.

The following defines your pause menu:

Code: Select all

screen game_menu:
    tag menu
    
    vbox:
        pos (0.5, 0.5)
        anchor (0.5, 0.5)
        textbutton _("Continue") action Return()
        textbutton _("Save Game") action ShowMenu("save")
        textbutton _("Load Game") action ShowMenu("load")
        textbutton _("Preferences") action ShowMenu("preferences")
        textbutton _("Main Menu") action MainMenu()
        textbutton _("Help") action Help()
        textbutton _("Quit") action Quit()
It's a fairly rudimentary screen; no background or anything like that.
You can replace your textbuttons with imagebuttons, or use an imagemap, to customize the appearance.

Now, all you need to do, is tell your game this is the screen you want to appear on ESC or right-click.
Make sure to put this code at the beginning of your game (after the start label):

Code: Select all

$ _game_menu_screen = "game_menu"
For advanced users:
If there's a scene where you want your players to be unable to pause the game, you can do the following:

Code: Select all

$ _game_menu_screen = None

#your scene here

$ _game_menu_screen = "game_menu"
And they won't be able to access the pause menu during the scene. Use sparingly.
For example, during an ATL-based cutscene.
Last edited by Greeny on Sun Jul 21, 2013 7:11 am, edited 1 time in total.
In Orbit [WIP] | Gliese is now doing weekly erratic VN reviews! The latest: Halloween Otome!
Gliese Productions | Facebook | Twitter
Image

User avatar
noeinan
Eileen-Class Veteran
Posts: 1126
Joined: Sun Apr 04, 2010 10:10 pm
Projects: Ren'Py QuickStart, Crimson Rue
Organization: Statistically Unlikely Games
Deviantart: noeinan
Github: noeinan
Location: Washington State, USA
Contact:

Re: Easy guide to: Pause menu

#2 Post by noeinan » Sat Jul 20, 2013 8:06 am

Thank you for adding this!

I have currently put this in my code and wanted to add a clarifier: The line $ _game_menu_screen = "game_menu_screen" is actually $ _game_menu_screen = "game_menu" if you use the code in your instructions, and also this line must be after the start label, not before it.
Image

Image
Image

User avatar
Greeny
Miko-Class Veteran
Posts: 921
Joined: Sun Dec 20, 2009 10:15 am
Completed: The Loop, The Madness
Projects: In Orbit, TBA
Organization: Gliese Productions
Location: Cantankerous Castle
Contact:

Re: Easy guide to: Pause menu

#3 Post by Greeny » Sun Jul 21, 2013 7:12 am

Weird, though. I understand why, but setting it to "game_menu_screen" seems to work in my project!

I think I remember reading somewhere that Ren'Py will automatically add "_screen" if no such screen is found, but don't take my word for it.
In Orbit [WIP] | Gliese is now doing weekly erratic VN reviews! The latest: Halloween Otome!
Gliese Productions | Facebook | Twitter
Image

User avatar
noeinan
Eileen-Class Veteran
Posts: 1126
Joined: Sun Apr 04, 2010 10:10 pm
Projects: Ren'Py QuickStart, Crimson Rue
Organization: Statistically Unlikely Games
Deviantart: noeinan
Github: noeinan
Location: Washington State, USA
Contact:

Re: Easy guide to: Pause menu

#4 Post by noeinan » Sun Jul 21, 2013 11:01 am

Huh, I'm not sure. Actually using _screen at the end might still work? I tried getting rid of _screen since I noticed the screen name was technically "game_menu" BUT I did that before realizing I needed to post that after my start label. Perhaps both will work?
Image

Image
Image

User avatar
kisa
Veteran
Posts: 383
Joined: Sat Aug 27, 2011 7:08 pm
Completed: Brother Rose, Dogs Alone
Projects: So many projects, I can't name them.
Deviantart: tsubasafan135
Skype: Discord: Kisaofbishies#6680
itch: kisa
Contact:

Re: Easy guide to: Pause menu

#5 Post by kisa » Thu Jun 26, 2014 7:59 pm

Ooh... This looks useful. *yoink*
I'm offering commissions!
viewtopic.php?f=62&t=41656

Post Reply

Who is online

Users browsing this forum: No registered users