Auto-dismissed screen on a new layer [Resolved]

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
bobconway
Regular
Posts: 132
Joined: Mon Sep 18, 2017 12:53 pm
Completed: Whale's Waldo, Xenopathy, YAGS, Earth Boys are Easy, Charles 2.0, YAGS Booty Call
Projects: http://bobcgames.com
Tumblr: bobcgames
itch: bobcgames
Contact:

Auto-dismissed screen on a new layer [Resolved]

#1 Post by bobconway »

I want to be able to show a notification to the user that will stick around for a few seconds and then dismiss itself.

If I show it on the overlay layer, it works, except that subsequent interactions like character dialogue dismiss it prematurely. I'm trying instead to stick it on a new layer, but then I can't seem to dismiss it, and it just hangs around forever.

I added a new layer

Code: Select all

init:
    python:
        config.top_layers = ['popupnotice']
Then I defined my screen

Code: Select all

screen mynotice(boxtext):
    tag mynoticealert
    fixed:
        image "sp/noticebg.png" at Position(xpos=0.85, ypos=0.1, xanchor=0.5, yanchor=0.5)
        text boxtext id "noticetext" at Position(xpos=0.85, ypos=0.1, xanchor=0.5, yanchor=0.5) xmaximum 290 ymaximum 90
    timer 3.0 action Hide("mynotice")
If I show the screen with layer="overlay", it dismisses itself properly (again, assuming no interaction occurs first that clears the overlay layer):

Code: Select all

def execute_notice(what):
    renpy.show_screen("mynotice", _layer="overlay", boxtext=what)
But the same thing on the new popupnotice layer never dismisses

Code: Select all

def execute_notice(what):
    renpy.show_screen("mynotice", _layer="popupnotice", boxtext=what)
The Hide action doesn't seem to take any layer parameters, unlike the renpy.hide_screen() statement, so I'm not sure how else I can automatically dismiss it.
Last edited by bobconway on Mon Oct 09, 2017 1:37 am, edited 1 time in total.
Image

See my other games here or find me on Twitter

User avatar
bobconway
Regular
Posts: 132
Joined: Mon Sep 18, 2017 12:53 pm
Completed: Whale's Waldo, Xenopathy, YAGS, Earth Boys are Easy, Charles 2.0, YAGS Booty Call
Projects: http://bobcgames.com
Tumblr: bobcgames
itch: bobcgames
Contact:

Re: Auto-dismissed screen on a new layer

#2 Post by bobconway »

It also doesn't work to use ui.timer with renpy.hide_screen, even though calling renpy.hide_screen from the same method does work:

This doesn't do anything:

Code: Select all

def hide_notice():
    renpy.hide_screen("mynotice", layer="popupnotice")
def execute_notice():
    renpy.show_screen("mynotice", _layer="popupnotice", boxtext=what)
    ui.timer(3.0, hide_notice)
But this shows and hides the notice after a click:

Code: Select all

def execute_notice():
    renpy.show_screen("mynotice", _layer="popupnotice", boxtext=what)
    renpy.pause()
    renpy.hide_screen("mynotice", layer="popupnotice")
As does this:

Code: Select all

def hide_notice():
    renpy.hide_screen("mynotice", layer="popupnotice")
def execute_notice():
    renpy.show_screen("mynotice", _layer="popupnotice", boxtext=what)
    renpy.pause()
    hide_notice()
which makes it seem like ui.timer is just never calling the associated function
Image

See my other games here or find me on Twitter

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: Auto-dismissed screen on a new layer

#3 Post by Divona »

Why not use "screens" layer? It's the same one Notify() use, I think:

Code: Select all

def execute_notice(what):
    renpy.show_screen("mynotice", _layer="screens", boxtext=what)
EDIT: If you insist, you could do this:

Code: Select all

    timer 3.0 action Function(renpy.hide_screen, tag="mynoticealert", layer="popupnotice")
Completed:
Image

User avatar
bobconway
Regular
Posts: 132
Joined: Mon Sep 18, 2017 12:53 pm
Completed: Whale's Waldo, Xenopathy, YAGS, Earth Boys are Easy, Charles 2.0, YAGS Booty Call
Projects: http://bobcgames.com
Tumblr: bobcgames
itch: bobcgames
Contact:

Re: Auto-dismissed screen on a new layer

#4 Post by bobconway »

Divona wrote: Sun Oct 08, 2017 10:05 pm Why not use "screens" layer? It's the same one Notify() use, I think
For some reason, that didn't occur to me at all. But yes, that works great.

Thank you!
Image

See my other games here or find me on Twitter

Post Reply

Who is online

Users browsing this forum: No registered users