Pause.Renpy Not Fully Working? (solved)

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
User avatar
noeinan
Eileen-Class Veteran
Posts: 1153
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:

Pause.Renpy Not Fully Working? (solved)

#1 Post by noeinan »

Image
So, above is a picture of the screen I'm working with, which allows the player to select their gender and occupation. The problem I'm having is that I've paused Ren'Py right after calling the screen, to allow the player to use this screen and not have to worry about the dialogue box-- *however* clicking on anything except the buttons will immediately bring up the dialogue box on top of the character select screen.

So, the player accidentally clicks out of a button and they will either get a message I programmed in just in case, telling them they haven't entered the right info and to try again, or they will get the option to accept the current stats and continue the game. I don't want this to happen-- I only want dialogue to be reactivated after the player has clicked the "Done" button.

If anyone has any advice on this, I'd greatly appreciate it, here is my code:

Main Script

Code: Select all

label char_select:
    
    "Now, select your beginning."
    
    # The phrase in the brackets is the text that the game will display to prompt
    # the player to enter the name they've chosen.

    $ player_firstname = renpy.input("Given Name")

    $ player_firstname = player_firstname.strip()
    # The .strip() instruction removes any extra spaces the player may have typed by accident.

    #  If the player can't be bothered to choose a name, then we
    #  choose a suitable one for them:
    if player_firstname == "":
        $ player_firstname="Derya"
        
    $ player_surname = renpy.input("Family Name")
    $ player_surname = player_surname.strip()
    
    if player_surname == "":
        $ player_surname="Emin"
        
    $ player_age = renpy.input("Age")
    $ player_age = player_age.strip()
    
    if player_age == "":
        $ player_age="30"
    
    "Select your beginning."
    
    show screen charselect
    $ renpy.pause()
    
label char_confirm:

    if player_gender == "None" or player_job == "None":
        
        "Please select a gender and occupation."
        
        call screen charselect
        $ renpy.pause()
        jump char_confirm
        
    else:
        "This is the story of [player_firstname] [player_surname], [player_gender] age [player_age], working as an [player_job] in the capital city."
        menu:
            "No, write it again.":
                $ player_gender = "None"
                $ player_job = "None"
                jump char_select
            "I am ready.":
                jump meet_child
Charselect Screen

Code: Select all

##############################################################################
# Character Select
#
# The start of the game, select your beginning.

screen charselect:
    tag menu
    
    add "gui/charselect.png"
    
#    $ ui.input('', xpos 607, ypos 163)
#    $ player_age = ui.interact("Age")
#    $ player_age = player_age.strip()
    
#    if player_age == "":
#        $ player_age="30"
    
#    $ player_firstname = renpy.input("Given Name") xpos 542 ypos 240
#    $ player_firstname = player_firstname.strip()
    
#    if player_firstname == "":
#        $ player_firstname="Derya"
        
#    $ player_surname = renpy.input("Family Name") xpos 568 ypos 284
#    $ player_surname = player_surname.strip()
    
#    if player_surname == "":
#        $ player_surname="Emin"
        
    
    hbox:
        xpos 642 ypos 365
        spacing 10
        
        imagebutton auto "gui/female.button_%s.png" action SetVariable("player_gender", "female")
        imagebutton auto "gui/genderless.button_%s.png" action SetVariable("player_gender", "genderless")
        imagebutton auto "gui/male.button_%s.png" action SetVariable("player_gender", "male")
        
    if player_gender == "None" and player_job == "None":
        imagebutton auto "gui/charselect.genderless.ambassador_%s.png" xpos 467 ypos 328
    if player_gender == "None" and player_job == "ambassador":
        imagebutton auto "gui/charselect.genderless.ambassador_%s.png" xpos 467 ypos 328
    if player_gender == "None" and player_job == "doctor":
        imagebutton auto "gui/charselect.genderless.doctor_%s.png" xpos 467 ypos 328
    if player_gender == "None" and player_job == "historian":
        imagebutton auto "gui/charselect.genderless.historian_%s.png" xpos 467 ypos 328
    if player_gender == "None" and player_job == "sorcerer":
        imagebutton auto "gui/charselect.genderless.sorcerer_%s.png" xpos 467 ypos 328
        
    if player_gender == "female" and player_job == "None":
        imagebutton auto "gui/charselect.female.ambassador_%s.png" xpos 467 ypos 328
    if player_gender == "female" and player_job == "ambassador":
        imagebutton auto "gui/charselect.female.ambassador_%s.png" xpos 467 ypos 328
    if player_gender == "female" and player_job == "doctor":
        imagebutton auto "gui/charselect.female.doctor_%s.png" xpos 467 ypos 328
    if player_gender == "female" and player_job == "historian":
        imagebutton auto "gui/charselect.female.historian_%s.png" xpos 467 ypos 328
    if player_gender == "female" and player_job == "sorcerer":
        imagebutton auto "gui/charselect.female.sorcerer_%s.png" xpos 467 ypos 328
        
    if player_gender == "genderless" and player_job == "None":
        imagebutton auto "gui/charselect.genderless.ambassador_%s.png" xpos 467 ypos 328
    if player_gender == "genderless" and player_job == "ambassador":
        imagebutton auto "gui/charselect.genderless.ambassador_%s.png" xpos 467 ypos 328
    if player_gender == "genderless" and player_job == "doctor":
        imagebutton auto "gui/charselect.genderless.doctor_%s.png" xpos 467 ypos 328
    if player_gender == "genderless" and player_job == "historian":
        imagebutton auto "gui/charselect.genderless.historian_%s.png" xpos 467 ypos 328
    if player_gender == "genderless" and player_job == "sorcerer":
        imagebutton auto "gui/charselect.genderless.sorcerer_%s.png" xpos 467 ypos 328
        
    if player_gender == "male" and player_job == "None":
        imagebutton auto "gui/charselect.male.ambassador_%s.png" xpos 467 ypos 328
    if player_gender == "male" and player_job == "ambassador":
        imagebutton auto "gui/charselect.male.ambassador_%s.png" xpos 467 ypos 328
    if player_gender == "male" and player_job == "doctor":
        imagebutton auto "gui/charselect.male.doctor_%s.png" xpos 467 ypos 328
    if player_gender == "male" and player_job == "historian":
        imagebutton auto "gui/charselect.male.historian_%s.png" xpos 467 ypos 328
    if player_gender == "male" and player_job == "sorcerer":
        imagebutton auto "gui/charselect.male.sorcerer_%s.png" xpos 467 ypos 328
    
    hbox:
        xpos 642 ypos 462
        spacing 10
        
        imagebutton auto "gui/ambassador.button_%s.png" action SetVariable("player_job", "ambassador")
        imagebutton auto "gui/doctor.button_%s.png" action SetVariable("player_job", "doctor")
        imagebutton auto "gui/historian.button_%s.png" action SetVariable("player_job", "historian")
        
    imagebutton auto "gui/sorcerer.button_%s.png" action SetVariable("player_job", "sorcerer") xpos 642 ypos 518
        
    imagebutton auto "gui/charselect.done_%s.png" action [Hide("charselect"), Jump("char_confirm")] xpos 505 ypos 578
Last edited by noeinan on Sat Jul 04, 2015 2:21 pm, edited 1 time in total.
Image

Image
Image

User avatar
SinnyROM
Regular
Posts: 166
Joined: Mon Jul 08, 2013 12:25 am
Projects: Blue Birth
Organization: Cosmic Static Games
Contact:

Re: Pause.Renpy Not Fully Working?

#2 Post by SinnyROM »

You can try adding modal True to your screen, then the screen will have complete focus until it's interacted with. I haven't tested it with the tag menu in there though.

User avatar
noeinan
Eileen-Class Veteran
Posts: 1153
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: Pause.Renpy Not Fully Working?

#3 Post by noeinan »

I totally derped and forgot about modal-- that worked, thanks.
Image

Image
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: Pause.Renpy Not Fully Working? (solved)

#4 Post by PyTom »

You probably want call screen, rather than show screen.
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

User avatar
noeinan
Eileen-Class Veteran
Posts: 1153
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: Pause.Renpy Not Fully Working? (solved)

#5 Post by noeinan »

I was under the impression that they were basically the same-- if you don't mind, what are the functional differences between the two? (A quick search didn't turn up comprehensive results, just that "call screen" shows and then hides the screen again.)

Is there an advantage to using call screen, instead of show screen and then returning with a button?
Image

Image
Image

User avatar
trooper6
Lemma-Class Veteran
Posts: 3712
Joined: Sat Jul 09, 2011 10:33 pm
Projects: A Close Shave
Location: Medford, MA
Contact:

Re: Pause.Renpy Not Fully Working? (solved)

#6 Post by trooper6 »

Edited to make my language more precide: Thanks Xela!
They are different. Here is how I understand it.

Show screen just shows a screen. You are still in the flow of the game. So you can continue clicking forward. This is useful for when you have screens you want to have up continuously while the game is running, like a clock screen or a screen you don't want to stop the flow of the game...like maybe at any time the player can press a button to show an inventory list, but you don't want showing that list to take you out of the game.

Call Screen pauses the game-flow and doesn't start it again until it receives a return. You go pull up a screen and you can't do anything with any other part of the game until you return (which then hides that screen).

Here is a little tester code the shows the difference:

Code: Select all

default val = 0

screen show_edit_value():
    frame align(0.0,0.0):
        hbox:
            text "[val]"
            textbutton "+" action SetVariable("val", val + 1)
            textbutton "-" action SetVariable("val", val - 1)

screen call_edit_value():
    frame align(1.0,0.0):
        hbox:
            text "[val]"
            textbutton "+" action SetVariable("val", val + 1)
            textbutton "-" action SetVariable("val", val - 1)
            textbutton "Return" action Return(True)
    
label start:
    $ renpy.retain_after_load() #This is here so that if you save in the middle of clicking buttons but before you "lock that change in" by moving to the next statement, it'll still be saved.
    show screen show_edit_value()
    "So here we are showing your screen."
    "There is no return button, because we aren't calling this menu...so we don't need it."
    "You can just play with the buttons and it'll change the value, but you can see the game is still moving along."
    "Value: [val]"
    #hide screen show_edit_value
    "So let's call our other screen. Before I do, I'll point out a few things. You'll notice this screen has a return button, because when you call this screen you'll have paused the game flow and won't be able to leave it without retuning."
    "Notice also that the say window disappears, this is my little indicator that we are in the world of the paused game flow." 
    "Play with the number, try to click anywhere else, and then  when you want to get back to the game, hit return."
    call screen call_edit_value()
    "Value: [val]"
    "Hope that clears up the difference for you."
    return
EDITS: I've done some experiments with the renpy.context_nesting_level() and the renpy.call_stack_depth() functions...also having the return button on both the show screen and the call screen. Here is what I learned.
1) Calling the screen does not create a new context. (This is the official programming term context)
2) Calling the screen also does not increase the call stack depth...so it isn't like a regular call. This explains this funny thing I noticed. When I had both the show screen with a return button and the call screen with the return button...I could click out of the call screen and un-pause game flow by clicking on any return button, including the return button on the show screen...not just the return button on the call screen.

Yay! Experiments!
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)
Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978

User avatar
xela
Lemma-Class Veteran
Posts: 2481
Joined: Sun Sep 18, 2011 10:13 am
Contact:

Re: Pause.Renpy Not Fully Working? (solved)

#7 Post by xela »

daikiraikimi wrote:I was under the impression that they were basically the same-- if you don't mind, what are the functional differences between the two? (A quick search didn't turn up comprehensive results, just that "call screen" shows and then hides the screen again.)

Is there an advantage to using call screen, instead of show screen and then returning with a button?
Just to avoid any confusion:

- called screen will hide the screen at the end of current interaction automatically.
- shown screen with a modal will be displayed on top of all other screens.

there is nothing more to it. Functional difference is logical when derived from the above statements, you'll mess up the game-flow (for example) if you hide a called screen without ending the current interaction. Showing any screen, modal or not, will run the next statement as well which is not always desirable.
Like what we're doing? Support us at:
Image

User avatar
noeinan
Eileen-Class Veteran
Posts: 1153
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: Pause.Renpy Not Fully Working? (solved)

#8 Post by noeinan »

Thanks for all the help, folks! So, in my understanding, if I were to use call screen instead, I wouldn't have to pause renpy manually. But I can still get the same functionality *in this specific case* by using show screen with modal.

Call screen would reduce the amount of code I used (which may have optimization benefits?) Show screen with modal is more useful if you have lots of screens displaying at once because otherwise buttons on other screens will still be active (such as the return button from another screen taking you back.)
Image

Image
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: Pause.Renpy Not Fully Working? (solved)

#9 Post by PyTom »

Basically, "call screen" is used for screens that block, interacting with the user, until a value is returned. You can think of these as menus, broadly construed - things the user interacts with.

"show screen" is used to put up screens that stay up. Overlay-type screens that display information to the user or provide access to other interfaces, for example.
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

User avatar
noeinan
Eileen-Class Veteran
Posts: 1153
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: Pause.Renpy Not Fully Working? (solved)

#10 Post by noeinan »

Thanks for the clarification!
Image

Image
Image

Post Reply

Who is online

Users browsing this forum: Exabot [Bot], fufuffiero, Sugar_and_rice