quit / confirm quit screen

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
Ocircuit
Regular
Posts: 39
Joined: Sun Jul 15, 2007 5:47 pm
Contact:

quit / confirm quit screen

#1 Post by Ocircuit »

Ok, I know I'm asking questions like crazy but I figure they're probably also useful to someone other than me and I really need help (programming and code just confuses the hell outta me).
I'm making my own custom menus and screens and I wanted to make my own quit confirm screen, so I was able to make one and it functions correctly except for one thing....

When you get the quit confirm screen you have the option of 'yes' or 'no' to quit, if you select yes its fine because it exits the game, however I'm having some difficulty with the "no' option. what i want is for if you select 'No' that it will return you to what ever screen or part of the game you were at when you first invoked the quit confirm screen. I can't figure out what code to use for that...If I use the following It works fine as long as you invoke the quit confirm screen while IN gameplay:

Code: Select all


label confirm_quit:
    

$ result = renpy.imagemap("benizukimiquit.bmp", "benizukimiquithov.bmp", [
                           (213, 153, 263, 200, "yes"),
                           (350, 153, 400, 200, "no")])

if result == "yes":
    jump _quit

elif result == "no":
    return
    
But, the quit confirm screen can also be triggered from the main menu (as well as anywhere in the game including save/load if the player just clicks the 'X' button on the top right of the window). Using the code above, if you trigger the quit confirm screen from the main menu or by clicking the 'X' button and you select 'No', rather than bring you back to the main menu (or what ever menu you may be in) it brings you instead to the game's start.

I'm sure theres an easy fix for this, but I have no idea what it is. Can someone please help me out?
Image

User avatar
PyTom
Ren'Py Creator
Posts: 16096
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: quit / confirm quit screen

#2 Post by PyTom »

Instead of having the main menu jump directly to confirm_quit, have it call it in a new context, using code like:

Code: Select all

if result == "quit":
    $ renpy.call_in_new_context("confirm_quit")
    jump main_menu
calling _quit will then cause the game to quit, while having confirm_quit return will return control to the next line, which will restart the menu.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

Ocircuit
Regular
Posts: 39
Joined: Sun Jul 15, 2007 5:47 pm
Contact:

Re: quit / confirm quit screen

#3 Post by Ocircuit »

thanks! actually from the main menu I didn't have the option to quit, only start and load (for this vn, im actually working on 2) but you can still exit at the main menu or at any menu (save/load etc) just by clicking on the 'X' on the game window, so how would I make that work? Say the player is in the save screen and they hit the 'X' tab, when the prompt comes up if they click "no" I want it to just put them back where they were in the save screen, same goes for what ever screen or menu they maybe in. The default renpy settings work this way, I was hoping there was a way to keep that even with a custom menu.
Image

Post Reply

Who is online

Users browsing this forum: Bing [Bot]