Hiding a screen with delay/timer.[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
xela
Lemma-Class Veteran
Posts: 2481
Joined: Sun Sep 18, 2011 10:13 am
Contact:

Hiding a screen with delay/timer.[Solved]

#1 Post by xela » Thu Oct 17, 2013 2:40 pm

What would be the best way to hide a screen 10 seconds after show or call (call preferably, to resume the code afterwards)? It has to be done from a python block so jumping to a different label is not an option (as rest of python code would not be executed). If possible, it should still be allowed to use a button to close it prematurely.

I've tried starting a new thread with a timer to run renpy.hide_screen() function, but for some reason, that did not work :(
Last edited by xela on Thu Oct 17, 2013 3:52 pm, edited 1 time in total.
Like what we're doing? Support us at:
Image

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

Re: Hiding a screen with delay/timer.

#2 Post by Tsapas » Thu Oct 17, 2013 3:24 pm

Should be fairly easy with time.sleep.

in init block use

Code: Select all

init python:
    import time
and in python block

Code: Select all

        time.sleep(amount of seconds)  
and then whatever you use to hide the screen.

Just tried it in a renpy screen using python blocks and works flawlessly.

Or break the python block with renpy.pause and carry on afterwards, but haven't tried it myself.

User avatar
Alex
Lemma-Class Veteran
Posts: 2981
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: Hiding a screen with delay/timer.

#3 Post by Alex » Thu Oct 17, 2013 3:42 pm

Like this?

Code: Select all

screen test_scr:
    timer 5.0 action [Hide("test_scr"), Return("value")]
    textbutton "X" action [Hide("test_scr"), Return("value")] xalign 1.0 yalign 0.05
    
label start:
    "Line 1"
    python:
        renpy.say(None, "Line 2")
        a = renpy.call_screen("test_scr")
        renpy.say(None, "[a]")

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

Re: Hiding a screen with delay/timer.

#4 Post by xela » Thu Oct 17, 2013 3:44 pm

Tsapas wrote:Should be fairly easy with time.sleep.

in init block use

Code: Select all

init python:
    import time
and in python block

Code: Select all

        time.sleep(amount of seconds)  
and then whatever you use to hide the screen.

Just tried it in a renpy screen using python blocks and works flawlessly.

Or break the python block with renpy.pause and carry on afterwards, but haven't tried it myself.
Thanks for trying but this solves non of my problems :( and you'd think if I knew how to create a new logical thread with it's own timer, I'd try this as well before posting a question here...

There should be a simple solution to this...

=====================================
Here is the simple solution:
Alex wrote:Like this?

Code: Select all

timer 5.0 action [Hide("screen")]
Yeap, that's exactly what I wanted, thank you :)
Like what we're doing? Support us at:
Image

User avatar
jghibiki
Regular
Posts: 125
Joined: Wed Sep 19, 2012 9:08 pm
Projects: Dream's Dénouement, Unannounced RPG framework, Renpy-Safe Logger
Organization: Team Anarky
IRC Nick: jghibiki
Location: Minnesota, US
Contact:

Re: Hiding a screen with delay/timer.

#5 Post by jghibiki » Thu Oct 17, 2013 4:01 pm

You might be able to do this using overlay screens. The following example would show "Hello" over you're in-game content for 5 seconds before making disappear

e.g.
init python:
import time
showScreen = False

def myOverlay():
if showScreen:
ui.text("Hello!")
ui.timer(5.0, ToggleVariable(showScreen)

label myLabel:
"Before showing text/starting counter"
$showScreen = True
"Stuff can still happen here"
"Eventually the timer will time out and the text will disappear."
_______________________________________
jghibiki
Web/Twitter/Tumblr

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

Re: Hiding a screen with delay/timer.

#6 Post by xela » Thu Oct 17, 2013 4:16 pm

jghibiki wrote:You might be able to do this using overlay screens. The following example would show "Hello" over you're in-game content for 5 seconds before making disappear

e.g.
init python:
import time
showScreen = False

def myOverlay():
if showScreen:
ui.text("Hello!")
ui.timer(5.0, ToggleVariable(showScreen)

label myLabel:
"Before showing text/starting counter"
$showScreen = True
"Stuff can still happen here"
"Eventually the timer will time out and the text will disappear."
That's once again, not what I've asked. You don't need to import time for RenPy's timers to work btw.

It's a complex screen with 200 lines of code and four different transforms running on it for a duration of 10 seconds. I should have looked into screen language for answer but I've seem to have developed a bad habit of looking for complicated answers in Python before checking in with RenPy :( (I did try several RenPy approaches as well, just never figured to look at the screen language erroneously thinking that I remember all of it...)

In any case, Alex's on screen timer solution works perfectly.
Like what we're doing? Support us at:
Image

Elementario
Newbie
Posts: 9
Joined: Wed Oct 10, 2018 4:26 am
Contact:

Re: Hiding a screen with delay/timer.[Solved]

#7 Post by Elementario » Sun Jul 14, 2019 3:24 am

Hi, so I know this is a old thread but I am really trying to look for a solution and can't find it anywhere,
So, I use a sort of achievement system to show a little pop up every now and then if a certain action is done.
The problem I have is that if the achievement pop up is still showing and someone rollsback, the timer breaks and never hides the given screen, any help?

Post Reply

Who is online

Users browsing this forum: enaielei