Clearing a screen after ui.interact()

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
marigoldsofthenight
Regular
Posts: 44
Joined: Sat Aug 14, 2010 5:31 pm
Contact:

Clearing a screen after ui.interact()

#1 Post by marigoldsofthenight » Thu Mar 06, 2014 6:20 pm

I have a section of my novel where the user must press the right button on a keypad. I have made the keypad as a separate screen, everything is working well, but I want to get rid of it after the button has been pressed. Here's the code thus far in the main script:

Code: Select all

label keypadtest:    
    o "I'm going to show you a keypad. Please press 7." 
    show screen keypad
    $renpy.pause()
    
    while True: 
        $ result = ui.interact()
    
I use ui.interact() to keep the keypad screen up there (it's a screen full of text buttons that emulates the numbers on a phone). What command do I use to tell repy to close that screen after a particular button has been pressed?

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

Re: Clearing a screen after ui.interact()

#2 Post by xela » Thu Mar 06, 2014 7:17 pm

marigoldsofthenight wrote:I have a section of my novel where the user must press the right button on a keypad. I have made the keypad as a separate screen, everything is working well, but I want to get rid of it after the button has been pressed. Here's the code thus far in the main script:

Code: Select all

label keypadtest:    
    o "I'm going to show you a keypad. Please press 7." 
    show screen keypad
    $renpy.pause()
    
    while True: 
        $ result = ui.interact()
    
I use ui.interact() to keep the keypad screen up there (it's a screen full of text buttons that emulates the numbers on a phone). What command do I use to tell repy to close that screen after a particular button has been pressed?
This is not something you use a while loop for, especially not with one key... either call the keypad or have 7 return some you can intercept (like a string/integer or string inside of a list/tuple) and hide the screen/terminate the loop at that return. I would have honestly used call screen here, while loop is redundant unless it needs to handle huge amounts of logic like in Battle Engines/Complex Inventories/Complex profile screens etc.
Like what we're doing? Support us at:
Image

marigoldsofthenight
Regular
Posts: 44
Joined: Sat Aug 14, 2010 5:31 pm
Contact:

Re: Clearing a screen after ui.interact()

#3 Post by marigoldsofthenight » Thu Mar 06, 2014 8:44 pm

xela wrote:
This is not something you use a while loop for, especially not with one key... either call the keypad or have 7 return some you can intercept (like a string/integer or string inside of a list/tuple) and hide the screen/terminate the loop at that return. I would have honestly used call screen here, while loop is redundant unless it needs to handle huge amounts of logic like in Battle Engines/Complex Inventories/Complex profile screens etc.

Much obliged! Still learning how all of these screens and whatnot work. Thank you for pointing me in the right direction. Problem solved now! :D

Post Reply

Who is online

Users browsing this forum: Bing [Bot]