<<Solved>> Can I make a yes/no prompt before the main 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
Ace94
Regular
Posts: 113
Joined: Sat Apr 08, 2017 4:22 pm
Contact:

<<Solved>> Can I make a yes/no prompt before the main screen?

#1 Post by Ace94 »

Is this possible? Something the user has to click yes or no and if he clicks no the game closes automatically. I checked the guide on the yes/no prompt, but I didn't see an option for before the main screen.
Last edited by Ace94 on Sat Oct 21, 2017 10:32 am, edited 1 time in total.

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3784
Joined: Mon Dec 14, 2015 5:05 am
itch: Imperf3kt
Location: Your monitor
Contact:

Re: Can I make a yes/no prompt before the main screen?

#2 Post by Imperf3kt »

Easily doable, just add a splashscreen and "call" a new screen you create in modal with two buttons. One button does "return", the other button does "action Quit(confirm=False)"
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor

Twitter

User avatar
Belgerum
Regular
Posts: 110
Joined: Thu Nov 06, 2014 12:24 am
Skype: belgerum09
Soundcloud: Belgerum
itch: Belgerum
Contact:

Re: Can I make a yes/no prompt before the main screen?

#3 Post by Belgerum »

Renpy already comes with a Yes/No confirm screen by default. You can use it like this:

Code: Select all

label splashscreen:
    call screen confirm(message="Proceed to play the game?", yes_action=Return(), no_action=Quit(confirm=False))
    return
Last edited by Belgerum on Fri Oct 20, 2017 7:18 pm, edited 1 time in total.

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3784
Joined: Mon Dec 14, 2015 5:05 am
itch: Imperf3kt
Location: Your monitor
Contact:

Re: Can I make a yes/no prompt before the main screen?

#4 Post by Imperf3kt »

That screen encompasses every yes/no prompt and will not be as customisable as something like the following though.

Code: Select all

label splashscreen:
    call proceed
    #"proceed" is just a random name for a screen I created, you could call it anything not on the Renpy special names list.
    return
    
screen proceed():
    tag menu
    modal True
    
    text _("This game contains gratuitous amounts of text\nDo you wish to continue?")
    
    textbutton _("Yes") action Return()
    Textbutton _("No") action Quit(confirm=False)
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor

Twitter

User avatar
Belgerum
Regular
Posts: 110
Joined: Thu Nov 06, 2014 12:24 am
Skype: belgerum09
Soundcloud: Belgerum
itch: Belgerum
Contact:

Re: Can I make a yes/no prompt before the main screen?

#5 Post by Belgerum »

True, but using the default confirm screen is the quickest and easiest solution to the problem, requiring no additional code, resources or complex knowledge of screen language. In many cases, it would be preferable, since it keeps the game's style consistent. If you want more customization, a new screen could definitely work better if you know how to program it, but the code for such a screen would be more dependent on the specific project.

In the context of this thread, both solutions are viable. I'm only giving a simpler option in case that's what the OP wanted, and providing an example that can be used in most game builds.

Ace94
Regular
Posts: 113
Joined: Sat Apr 08, 2017 4:22 pm
Contact:

Re: Can I make a yes/no prompt before the main screen?

#6 Post by Ace94 »

Thank you. I managed to do it with your help, guys.

I just have one last question which is important for me: Can I make the screen appear only once when the user starts the game for the very first time? Of course it won't appear again if he clicks Yes or Confirm, but if he clicks No it will appear again. Is this possible and how?

User avatar
Divona
Miko-Class Veteran
Posts: 678
Joined: Sun Jun 05, 2016 8:29 pm
Completed: The Falconers: Moonlight
Organization: Bionic Penguin
itch: bionicpenguin
Contact:

Re: Can I make a yes/no prompt before the main screen?

#7 Post by Divona »

Ace94 wrote: Sat Oct 21, 2017 6:57 am Can I make the screen appear only once when the user starts the game for the very first time? Of course it won't appear again if he clicks Yes or Confirm, but if he clicks No it will appear again. Is this possible and how?
Use persistent data.

Code: Select all

default persistent.show_confirm = False

label splashscreen:

    if persistent.show_confirm == False:
        call screen confirm(
            message = "Proceed to play the game?",
            yes_action = Return(),
            no_action = Quit(confirm=False))
            
        $ persistent.show_confirm = True
        
    return
Completed:
Image

Ace94
Regular
Posts: 113
Joined: Sat Apr 08, 2017 4:22 pm
Contact:

Re: Can I make a yes/no prompt before the main screen?

#8 Post by Ace94 »

edit: nvm it seems it did work!!!

Thank you so much! I clicked Yes and it remembered my choice next time I launched the project. Can I test this again somehow? I tried deleting the code, saving and then pasting it back in, but it still remembers my choice. Any idea how I can test this again?

This is the code I used btw:

Code: Select all

screen proceed():
    tag menu
    modal True
    
    add "gui/yesno_ground.png"
    
    imagebutton auto "gui/yesno_yes_%s.png" xpos 550 ypos 685 hover_sound "sfx/click.wav" action Return()
    imagebutton auto "gui/yesno_no_%s.png" xpos 911 ypos 685 hover_sound "sfx/click.wav" action Quit(confirm=False)

default persistent.show_proceed = False

label splashscreen:
    
    if persistent.show_proceed == False:
        call screen proceed
        
        $ persistent.show_proceed = True

    return
I figured it out. I just had to delete the "persistent" file that is located at both save game folders that you have (One in the project folder and one in C:)

Post Reply

Who is online

Users browsing this forum: Google [Bot], myself600, sine12