How to disable quit_action on main menu only?

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
bitgraphic
Regular
Posts: 54
Joined: Fri Aug 02, 2013 8:53 pm
Location: Japan
Contact:

How to disable quit_action on main menu only?

#1 Post by bitgraphic »

my game autosaves when i close the game from mainmenu (because it autosaves everytime quit_action occur)
i'd like to disable it only at the main menu

I tried this code i made myself, but It doesn't work

Code: Select all

init python:
    in_title = False
    if not in_title:
        config.quit_action = Quit(confirm=False)

label start:
    $ in_title = True
2013-12-13 19-51-43.jpg

Tsapas
Regular
Posts: 69
Joined: Mon Oct 14, 2013 8:18 am
Contact:

Re: How to disable quit_action on main menu only?

#2 Post by Tsapas »

This just controls whether you get a Yes/No prompt when quiting

Code: Select all

 config.quit_action = Quit(confirm=False)
Since you use an in_title trigger to control autosave, try this in 00layout.rpy
(the 00layout.rpy has an init python block with a -1400 priority. If you get errors try defining in_title with a -1401 priority or move it in 00layout.rpy)

Code: Select all

label _quit_prompt:
    if in_title: #add this check
        $ renpy.loadsave.force_autosave()

    if layout.invoke_yesno_prompt(None, layout.QUIT):
        jump _quit
    else:
        return
And use this as you did

Code: Select all

init python:
    in_title = False

label start:
    $ in_title = True

bitgraphic
Regular
Posts: 54
Joined: Fri Aug 02, 2013 8:53 pm
Location: Japan
Contact:

Re: How to disable quit_action on main menu only?

#3 Post by bitgraphic »

Tsapas, I can't thank you enough.
You are the best!

and yes, it worked perfectly ;)

Tsapas
Regular
Posts: 69
Joined: Mon Oct 14, 2013 8:18 am
Contact:

Re: How to disable quit_action on main menu only?

#4 Post by Tsapas »

Btw, you may wanna add this too in 00layout.rpy

Code: Select all

label _main_menu_prompt:
    $ renpy.loadsave.force_autosave()
    if layout.yesno_prompt(None, layout.MAIN_MENU):
        $ in_title = False #add this
        $ renpy.full_restart(transition=config.game_main_transition)
    else:
        return
Because, if the user plays a bit, then go back to main menu (it will autosave properly) and then quit, it will still autosave since the in_title will be True. (Unless you have a way of changing it already, so disregard this).

User avatar
PyTom
Ren'Py Creator
Posts: 16093
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: How to disable quit_action on main menu only?

#5 Post by PyTom »

FWIW, I think this was fixed in 6.16.
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

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot], Galo223344, Google [Bot]