Ren'Py Hide $renpy.notify onclick

recreation

pure evil!
Respected User
Game Developer
Jun 10, 2018
6,250
22,145
This should be simple, but I can't figure it out:
$renpy.notify("sometext")

I want notify to hide instantly when the player clicks the screen but fade when not clicked.
So I tried it with a variable:
Code:
$ switchClick = False
screen notify(message):
    
    #blabla 

    key "mousedown_1" action [SetVariable("switchClick",True), Hide('notify')]

if switchClick:
    $ switchClick = False
    transform notify_appear:
        xalign .5 yalign .5
        on show:
            alpha 0
            linear .25 alpha 1.0
        on hide:
            alpha 0

else:
    transform notify_appear:
        xalign .5 yalign .5
        on show:
            alpha 0
            linear .25 alpha 1.0
        on hide:
            linear .5 alpha 0.0
switchClick gets set, but the notification screen still fades out. If I delete the else tree it does work, but of course it wont fade when the player does not click.
Any ideas?
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Respected User
Donor
Jun 10, 2017
10,108
14,776
Any ideas?

Haven't tried it and absolutely not sure that it will works, but what if you use something like this ?
Python:
screen notify:

    default clicked = False

    key "mousedown_1" action SetScreenVariable( "clicked",True)

    if clicked is False:
        use regularNotify
   else:
        use clickedNotify


screen regularNotify:

    transform notify_appear:
        xalign .5 yalign .5
        on show:
            alpha 0
            linear .25 alpha 1.0
        on hide:
            linear .5 alpha 0.0

screen clickedNotify:

    transform notify_appear:
        xalign .5 yalign .5
        on show:
            alpha 0
            linear .25 alpha 1.0
        on hide:
            alpha 0

    Timer 0.1 action Hide( "notify" )
 
  • Like
Reactions: recreation

recreation

pure evil!
Respected User
Game Developer
Jun 10, 2018
6,250
22,145
Well it threw some errors at first, tramsform can't be set in a screen as it seems. After I made some changes it ended up doing exactly the same as my try above :/
Python:
default clicked = False
screen notify(message):
   
    zorder 100
    style_prefix "notify"

    timer 2 action Hide('notify')

    key "mousedown_1" action SetScreenVariable("clicked",True)

    if clicked is False:
        frame at regularNotify:
            text "[message!tq]"
    else:
        frame at clickedNotify:
            text "[message!tq]"

transform regularNotify:
    xalign .5 yalign .5
    on show:
        alpha 0
        linear .25 alpha 1.0
    on hide:
        linear .5 alpha 0.0

transform clickedNotify:
    xalign .5 yalign .5
    on show:
        alpha 0
        linear .25 alpha 1.0
    on hide:
        alpha 0
 

Epadder

Programmer
Game Developer
Oct 25, 2016
567
1,047
Try this for the effect you're aiming for:

Code:
screen notify(message):
    default clicked = False
    zorder 100
    style_prefix "notify"

    key "mousedown_1" action SetScreenVariable("clicked",True)

    if clicked is False:
        frame at regularNotify:
            text "[message!tq]"
        timer 2 action Hide('notify')
    else:
        frame at clickedNotify:
            text "[message!tq]"
        timer 0.1 action Hide('notify')
 

recreation

pure evil!
Respected User
Game Developer
Jun 10, 2018
6,250
22,145
Try this for the effect you're aiming for:

Code:
screen notify(message):
    default clicked = False
    zorder 100
    style_prefix "notify"

    key "mousedown_1" action SetScreenVariable("clicked",True)

    if clicked is False:
        frame at regularNotify:
            text "[message!tq]"
        timer 2 action Hide('notify')
    else:
        frame at clickedNotify:
            text "[message!tq]"
        timer 0.1 action Hide('notify')
The timer, of course! Damn, I need to get my head straight o_O
Thanks a lot!