• To improve security, we will soon start forcing password resets for any account that uses a weak password on the next login. If you have a weak password or a defunct email, please update it now to prevent future disruption.

Ren'Py How to display a message or a menu, without the black screen in Renpy?

Scapest

Newbie
Jul 8, 2017
98
56
I'm trying to show a message when I click in a Imagebutton.

Code:
imagebutton:
        xpos 1272 ypos 261
        focus_mask True
        idle "Hud/overworldmark_idle.png"
        hover "Hud/overworldmark_hover.png"
        if unclickable == False:
            if time_of_day in ('MORNING', 'AFTERNOON'):
                action Hide("overworld_map"), Jump("college") hovered ShowTransient("label_college") unhovered Hide("label_college")
            else:
                action SetVariable("show_college_closed_message", True), Jump("college_closed_message")

label college_closed_message:
    $ unclickable = True
    if show_college_closed_message:
        n "College is closed right now."
        $ unclickable = False
        jump overworld_map
You don't have permission to view the spoiler content. Log in or register now.

or in a menu


Code:
label mcbedroom_menu:
    if daytime<4:
        menu:
            "Rest":
                #"Afternoon":    #imagebutton  transformar em label os horários
                    if daytime < 2:  # Verifica se é possível avançar para a tarde
                        $daytime = 2
                        jump change_timename
                #"Evening":  #imagebutton
                    if daytime < 3:  # Verifica se é possível avançar para a noite
                        $daytime = 3
                        jump change_timename
                #"Night":    #imagebutton
                    if daytime < 4:  # Verifica se é possível avançar para a noite
                        $daytime = 4
                        jump change_timename
            "Go to sleep": #imagebutton
                if daytime == 4:  # Verifica se é noite para permitir ir dormir
                    $lastplace="mc_room"
                    jump start_of_next_day
                else:
                    jump change_timename
    else:
        menu:
            "Go to sleep": #imagebutton
                if daytime == 4:  # Verifica se é noite para permitir ir dormir
                    $lastplace="mc_room"
You don't have permission to view the spoiler content. Log in or register now.



But every time, it shows the message or the menu, with a black screen, how can I show the message or the menu, with the background that already exists at the moment?
Do I need to call the screen again? or create a new one?
 

osanaiko

Engaged Member
Modder
Jul 4, 2017
2,149
3,510
Just glancing at your code a couple of things jumped out

1. I don't see anywhere that you are displaying a "scene" image which is the normal way to have a background behind a menu or Screen

2. the ImageButton does nothing (useful) unless contained by a Screen. Perhaps you cut out that part of the code for clarity, so maybe this is a red herring. please show full code if you are still having issues.

3. In Renpy Screen language, multiple actions must be enclosed in a Python List

Code:
    action SetVariable("show_college_closed_message", True), Jump("college_closed_message")
#should be
    action [SetVariable("show_college_closed_message", True), Jump("college_closed_message")]
 

Scapest

Newbie
Jul 8, 2017
98
56
Just glancing at your code a couple of things jumped out

1. I don't see anywhere that you are displaying a "scene" image which is the normal way to have a background behind a menu or Screen

2. the ImageButton does nothing (useful) unless contained by a Screen. Perhaps you cut out that part of the code for clarity, so maybe this is a red herring. please show full code if you are still having issues.

3. In Renpy Screen language, multiple actions must be enclosed in a Python List

Code:
    action SetVariable("show_college_closed_message", True), Jump("college_closed_message")
#should be
    action [SetVariable("show_college_closed_message", True), Jump("college_closed_message")]
You are totally right, I was not calling a scene, problem solved, thank you.

Code:
label college_closed_message_evening:
    $ unclickable = True
    if show_college_closed_message_evening:
        scene image "Places/City_map_evening_ground.jpg"
        n "College is closed right now."
        $ unclickable = False
        jump overworld_map
 
  • Like
Reactions: osanaiko

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Respected User
Donor
Jun 10, 2017
10,214
14,969
3. In Renpy Screen language, multiple actions must be enclosed in a Python List
It's not mandatory since a couple of years, yet I agree that it's more explicit and should be done that way.


This being said there's another thing that jumped out to my eyes, the use of a label for the message.

Something like
Python:
[...]
               action Show( "myNotify", "College is closed right now." )
[...]

screen myNotify( msg ):

    text "[msg]" xalign 0.5 yalign 0.5

    imagebutton:
        idle Solid( "#00000000" )
        xpos 0 ypos 0
        xsize config.screen_width
        ysize config.screen_height
        action Hide()
Would probably be better. At least after some styling of course.

Alternatively the screen can hide itself after (in the example) 3 seconds:
Python:
screen myNotify( msg ):

    timer 3 action Hide()

    text "[msg]" xalign 0.5 yalign 0.5