[Solved] Reason why screen is not showing using a conditional and renpy.show_screen()?

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
slithery eyed wombat
Newbie
Posts: 15
Joined: Sat Jun 02, 2018 5:45 pm
Contact:

[Solved] Reason why screen is not showing using a conditional and renpy.show_screen()?

#1 Post by slithery eyed wombat »

So I've got a screen that puts up an imagemap. I also want to have it put up a separate screen if the player has progressed enough in through the game. Here's my code:

Code: Select all

screen city_map_screen:

    python:
        if day > 2:
            renpy.show_screen("game_gui")

    imagemap:
    ...
This works the first time I call it.

Code: Select all

call screen city_map_screen
However, after navigating away then coming back to city_map_screen, the gui is no longer displayed. I've checked and day is still greater than 2.

Any ideas? Is the python statement wrong in some way?

More code. This is how I'm coming back to the city_map_screen.

Code: Select all

label next_night:

    hide screen game_gui

    $ day += 1
    
    call screen city_map_screen
edit:

I notice that, using my original code, when I mouse over any of my imagemap elements, the game_gui appears. Perhaps I need a way to force it to refresh when I first call the city_map_screen?
Last edited by slithery eyed wombat on Thu Mar 21, 2019 9:13 am, edited 2 times in total.

rames44
Veteran
Posts: 233
Joined: Sun May 29, 2016 4:38 pm
Contact:

Re: Reason why screen is not showing using a conditional and renpy.show_screen()?

#2 Post by rames44 »

Instead of

Code: Select all

screen city_map_screen:

    python:
        if day > 2:
            renpy.show_screen("game_gui")

    imagemap:
why not

Code: Select all

screen city_map_screen:

    if day > 2:
        use game_gui

    imagemap:
"use" is the "screen language way" of having one screen include another screen.
https://www.renpy.org/doc/html/screens.html#use

slithery eyed wombat
Newbie
Posts: 15
Joined: Sat Jun 02, 2018 5:45 pm
Contact:

Re: Reason why screen is not showing using a conditional and renpy.show_screen()?

#3 Post by slithery eyed wombat »

That doesn't seem to work.

In fact, now I'm not seeing game_gui at all, whether it's the first time or any subsequent time. Before I at least saw it the first time.

edit:

I notice that, using my original code, when I mouse over any of my imagemap elements, the game_gui appears. Perhaps I need a way to force it to refresh when I first call the city_map_screen?

slithery eyed wombat
Newbie
Posts: 15
Joined: Sat Jun 02, 2018 5:45 pm
Contact:

Re: Reason why screen is not showing using a conditional and renpy.show_screen()?

#4 Post by slithery eyed wombat »

Ok, I think I've solved it.

Step 1: take rames44's suggestion of using the use statement

Step 2: move it below the imagemap declaration

I'm guessing when I first tried rames44's suggestion, Renpy would draw the game_gui screen then draw over it with the imagemap. Reordering these in the code lets Renpy draw the imagemap first, then put the game_gui screen over top of it.

I still don't have an explanation as to why my original code behaved the way it did (why did it work as expected the first time but not on subsequent calls?)


User avatar
trooper6
Lemma-Class Veteran
Posts: 3712
Joined: Sat Jul 09, 2011 10:33 pm
Projects: A Close Shave
Location: Medford, MA
Contact:

Re: Reason why screen is not showing using a conditional and renpy.show_screen()?

#6 Post by trooper6 »

Just edit the title of your original post.
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)
Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978

Post Reply

Who is online

Users browsing this forum: Bing [Bot]