[Solved] on "hide" Show("another_screen_name") cancels the hiding - So both screens are now visible?

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
tornsoul
Regular
Posts: 29
Joined: Sat Jun 19, 2021 7:32 pm
Contact:

[Solved] on "hide" Show("another_screen_name") cancels the hiding - So both screens are now visible?

#1 Post by tornsoul »

The following code works fine - After the timer the screen is hidden as expected.

Code: Select all

screen test_hide_scr1():
    timer 2.0 action [Hide("test_hide_scr1")]
    textbutton "x1" action [Hide("test_hide_scr1")] xalign 0.5 yalign 0.5
    
label test_it:
    "Ready to test"
    show screen test_hide_scr1
    "Screen is showing"
    return

If however

Code: Select all

on "hide" Show("test_hide_scr2")
is added then the first screen is no longer hidden - and both screens now show

Code: Select all

screen test_hide_scr1():
    timer 2.0 action [Hide("test_hide_scr1")]
    textbutton "x1" action [Hide("test_hide_scr1")] xalign 0.5 yalign 0.5
    on "hide" action [Show("test_hide_scr2")]
    
screen test_hide_scr2():
    textbutton "x2" xalign 0.6 yalign 0.5
        

label test_it:
    "Ready to test"
    show screen test_hide_scr1
    "Screen is showing"
    return

Any suggestions how to fix - so the first screen still gets hidden...??
Last edited by tornsoul on Mon Jun 21, 2021 10:25 am, edited 1 time in total.

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

Re: on "hide" Show("another_screen_name") cancels the hiding - So both screens are now visible?

#2 Post by Alex »

tornsoul wrote: Sun Jun 20, 2021 6:36 pm ...Any suggestions how to fix - so the first screen still gets hidden...??
Give screens the same tag - https://www.renpy.org/doc/html/screens. ... -statement

tornsoul
Regular
Posts: 29
Joined: Sat Jun 19, 2021 7:32 pm
Contact:

Re: on "hide" Show("another_screen_name") cancels the hiding - So both screens are now visible?

#3 Post by tornsoul »

Thanks - That works!

Although I'd consider it more of a "workaround".
The "tag" should (imo) be used for conceptually "same type" of screen.
This could be two screens having nothing in common - in which case the use of the "tag" seems a bit "code smelly" (again imo)

And I still find it weird (a bug) that the "on 'hide' action Show...." should block the first screen from being hidden.
But I can work with this - So thanks again.

tornsoul
Regular
Posts: 29
Joined: Sat Jun 19, 2021 7:32 pm
Contact:

Re: [Solved] on "hide" Show("another_screen_name") cancels the hiding - So both screens are now visible?

#4 Post by tornsoul »

Seeing as we are (mis)using the "tag" mechanism instead:
The code don't need the "on 'hide'" event any longer and can instead be written as

Code: Select all

screen test_hide_scr1():
    tag test_hide_scr
    timer 2.0 action [Show("test_hide_scr2")]
    textbutton "x1" action [Show("test_hide_scr2")] xalign 0.5 yalign 0.5
    
screen test_hide_scr2():
    tag test_hide_scr
    textbutton "x2" xalign 0.6 yalign 0.5
        

label test_it:
    "Ready to test"
    show screen test_hide_scr1
    "Screen is showing"
    return
Which just further makes me believe the "on 'hide' Show(..." is bugged

tornsoul
Regular
Posts: 29
Joined: Sat Jun 19, 2021 7:32 pm
Contact:

Re: [Solved] on "hide" Show("another_screen_name") cancels the hiding - So both screens are now visible?

#5 Post by tornsoul »

It would appear that there indeed was a bug.

I reported it: https://github.com/renpy/renpy/issues/2865
and renpytom just committed a fix: https://github.com/renpy/renpy/commit/a ... 516f8df16c

I assume it is now fixed (without actually having tested with a new build of renpy)

Post Reply

Who is online

Users browsing this forum: No registered users