Opening the Save screen from a prompt

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
Human Bolt Diary
Regular
Posts: 111
Joined: Fri Oct 11, 2013 12:46 am
Contact:

Opening the Save screen from a prompt

#1 Post by Human Bolt Diary »

I'd like to implement a prompt asking the player if they want to save.

Using ShowMenu("save") as the Yes action hasn't worked. The save occurs with the prompt still present. Loading essentially traps the player at the prompt.

Alternatively, I've tried to have the Yes action send the player to another label where the save screen will be opened automatically for them.

To this end, I'm trying to use renpy.call_in_new_context(). However, doing so causes the save to occur before on the line before the save screen is called. When the game is loaded, the player is sent right back to the save screen via the next line, which is renpy.call_in_new_context().

The following is a minimal example of trying to use call_in_new_context in this way.

Code: Select all

# The script of the game goes in this file.

# Declare characters used by this game. The color argument colorizes the
# name of the character.

define e = Character("Eileen")


# The game starts here.

label start:

    # Show a background. This uses a placeholder by default, but you can
    # add a file (named either "bg room.png" or "bg room.jpg") to the
    # images directory to show it.

    scene bg room

    # This shows a character sprite. A placeholder is used, but you can
    # replace it by adding a file named "eileen happy.png" to the images
    # directory.

    show eileen happy

    # These display lines of dialogue.

    e "You've created a new Ren'Py game."

    $ renpy.call_in_new_context("_game_menu", _game_menu_screen="save")
    
    e "Once you add a story, pictures, and music, you can release it to the world!"

    # This ends the game.

    return

kivik
Miko-Class Veteran
Posts: 786
Joined: Fri Jun 24, 2016 5:58 pm
Contact:

Re: Opening the Save screen from a prompt

#2 Post by kivik »

To create a yes / no prompt: you need to use the confirm screen and assign the yes_action to saving: https://www.renpy.org/doc/html/screen_s ... ml#confirm

Code: Select all

call screen confirm("Do you want to save?", yes_action=[ShowMenu('save'), Return()], no_action=Return())
Note I put a list of screen actions into the yes_action parameter: show the save menu, then Return(), so the screen will be gone when you come out of the save menu.

It doesn't "trap" the player in the prompt when loading, but when the prompt will reappear upon loading and can be dismissed - and that's what I don't know how to prevent as Renpy seems to always re-execute the line you save at!

If you rephrase the question to something like "skip line after loading" maybe one of the veterans of the forums will see and help out?

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot]