RENPY: crazy screen

Cohibozz

Member
Aug 14, 2018
126
27
hi all, i've a problem with a screen in my code.

the set is livingroom.
i see in livingroom m char and bs char at different time of the day.

at 10 i see m
at 11 bs
at 12 again m
...
...
ok my problem is:
i see m, i have chat with her (bs_0_10 is a random menu not properly for bs, only menu choiche no image)
then i see bs and chat with her..
ok....

now if i chat agin with m i have the problem...i see always bs! the m scree disg0 not show! only the first time!
this is my code:
Code:
screen livingbackscreen_hm1:
    imagebutton auto "arrow_%s.png" xalign 0.5 yalign 1.0 focus_mask True action Call("livingroom_hm1")

screen livingbackscreen_hm2:
    imagebutton auto "arrow_%s.png" xalign 0.5 yalign 1.0 focus_mask True action Call("livingroom_hm2")

label livingroom_hm1:
    $whereim = "Livingroom"
    show screen navroom_m
    show screen daytime
    call screen livingroom_hm1
    screen livingroom_hm1:
        zorder 0
        modal True
        use bgsky
        add "hm1/livingroom/livingroom_hm1.png"
        if (time == 10) or (time == 12) or (time == 22):
            imagebutton auto "hm1/livingroom/m_livingroom_hm1_%s.png" xpos 1325 ypos 704 focus_mask True action Call("m_livingroom_hm1")
        if (time == 11) or (time == 13) or (time == 18) or (time == 19):
            imagebutton auto "hm1/livingroom/bs_livingroom_hm1_%s.png" xpos 1324 ypos 697 focus_mask True action Call("bs_livingroom_hm1")


label bs_livingroom_hm1:
    scene bs_livingroom_hm1
    show screen diag_bs_livingroom_hm1
    mc "Ciao [bsname]. Posso sedermi?"
    call bs_0_10
    call screen livingbackscreen_hm1
    screen diag_bs_livingroom_hm1:
        use bgsky
        add "hm1/livingroom/bs_livingroom_diag0_hm1.png"

label m_livingroom_hm1:
    scene m_livingroom_hm1
    show screen diag_m_livingroom_hm1
    mc "Hey [mname]. Posso farti compagnia?"
    call bs_0_10
    call screen livingbackscreen_hm1
    screen diag_m_livingroom_hm1:
        use bgsky
        add "hm1/livingroom/m_livingroom_diag0_hm1.png"
bs_livingroom_diag0_hm1.png m_livingroom_diag0_hm1.png
 
  • Like
Reactions: maxnen

Cohibozz

Member
Aug 14, 2018
126
27
there is a command to hide all screen at same time? i think i've some screen to hide in some scene but an hide all if possible it good to use at start of new screen
 

the66

beware, the germans are cumming
Modder
Donor
Respected User
Jan 27, 2017
7,809
24,389
if you call a label, this label needs a return or the code continues with the next label
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,971
16,229
if you call a label, this label needs a return or the code continues with the next label
In the same time it's probably not the problem here, since the labels end with a called screen that also don't have a return value. I don't want to know the size of the call stack at the end of a single game day.



hi all, i've a problem with a screen in my code.
You call, call everywhere... Are you sure that you understood how it works ? The statement, the screen action and the statement are not intended for one way branching. They need that you return at some time.
Like each label start with a statement, and because this statement reset, the screen, there's 90% chance that the problem you face is directly caused by the never returned called screens.
 
  • Like
Reactions: the66

Cohibozz

Member
Aug 14, 2018
126
27
if i need a screen to show imagebutton and stop the game until i click on it, if i use show screen it don't stop and go ahead in the next label... if i use call (also if i don't need call it because i don't need return) it stop and i can click the imagebutton.

how can i use show screen and stop the game until someting trigger (i.e. imagebutton?)
 

the66

beware, the germans are cumming
Modder
Donor
Respected User
Jan 27, 2017
7,809
24,389
you basically create an infinite loop

in label livingroom_hm1 you call the screen livingroom_hm1
this screen calls bs_livingroom_hm1/m_livingroom_hm1
both labels are calling the screen livingbackscreen_hm1
this screen calls label livingroom_hm1 and you are exactly where you began

do you see the problem?

calling a screen is absolut fine to interrupt the program for a user input but normally this screen returns a value that gets interpreted by the code after the screen call
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,971
16,229
how can i use show screen and stop the game until someting trigger (i.e. imagebutton?)
By calling it, but by calling it correctly.

Technically, the difference between "show screen" and "call screen" is that when you call the screen, Ren'py will enter in a waiting loop centered to this screen. This loop will end when Ren'py will have to execute a , or screen action. What will happen next depend of the said screen action.
If it's a Jump, then Ren'py will definitively transfer the control to the label passed as parameter.
If it's a Return, then Ren'py will go back to where the screen was called, and execute the statement right after the "call screen" one. Before this, it will store the value passed as parameter into the "_return" variable, for you to use it.
And finally if it's a Call, Ren'py will temporarily transfer the control to the label passed as parameter... expecting to found a return statement that will send it back to the original label, right after "call screen" the statement ; like for Return.

So, you've the choice. Here's one (among many) example for each screen action :
You don't have permission to view the spoiler content. Log in or register now.

You don't have permission to view the spoiler content. Log in or register now.

You don't have permission to view the spoiler content. Log in or register now.


This said, writing the last example lead me to the only possible explanation for your problem. But honestly it was simply impossible to find it, because there's nothing in the code you provided, that can give the start of a clue about it.
TL;DR: you see "bs" because there's a hidden return somewhere. I guess that it's the one coming from the default content of script.rpy, that follow the "m_livingroom_hm1" label, separated to it by many blank lines. But well, it's just a guess.

As for the explanation, like I said it's because of the lack of return wrote by yourself. This combined to the way Ren'py works.
Your code was :
Code:
label livingroom_hm1:
   [...]
   call screen livingroom_hm1
   screen livingroom_hm1:
      [...]

label bs_livingroom_hm1:
   scene bs_livingroom_hm1
   [...]
Here, the screen don't count.
Despite the indentation, Ren'py will never see it as other thing than a screen definition. It will never be part of the code that Ren'py will execute.
This is half wrong, but see it as true if you want to understand.

So, for Ren'py your code looks like this :
Code:
label livingroom_hm1:
   [...]
   call screen livingroom_hm1

label bs_livingroom_hm1:
   scene bs_livingroom_hm1
   [...]
Here come a specificity of the "label" statement. If it's used to create group of statements in the (so in the memory), as code it's just a branching point, nothing else.
It mean that once you reach the end of a label, Ren'py will just continue with the following line.

So, as code seen by Ren'py, what you wrote looks like this :
Code:
label livingroom_hm1:
   [...]
   call screen livingroom_hm1

   scene bs_livingroom_hm1
   [...]
Now, for some reason not seen in the code you provided, after showing "m_livingroom_hm1", Ren'py decide to return... It lead to this chain of events :
  • label livingroom_hm1
  • call screen livingroom_hm1
  • call bs_livingroom_hm1
  • call screen screen livingbackscreen_hm1
  • call label livingroom_hm1
  • call screen livingroom_hm1
  • call m_livingroom_hm1
  • call screen livingbackscreen_hm1
  • return -> go back to m_livingroom_hm1 after the "call screen"
  • return -> go back to livingroom_hm1 after the "call screen"
  • normally continue by executing bs_livingroom_hm1

I assume that you wrote your code by removing the scene and dialog line of the default content of "script.rpy"... added a bunch of blank line before the return it also contain, and inserted your code between it and "label start:".
But I'm not 100% sure of it. Like I said, the cause of your problem is not in the code you provided, but unless both @the66 and me missed something (what can happen), it's the only explanation to your problem.
 

Cohibozz

Member
Aug 14, 2018
126
27
Ty a lot! I'm so noob that i use screen , scene and label in really wrong way! but tank of your explanation (fantastic) i hope that now i've used the right on (now work properly!)

Code:
screen livingbackscreen:
    imagebutton auto "arrow_%s.png" xalign 0.5 yalign 1.0 focus_mask True action Return("livingroom")


label livingroom_hm1:
    $whereim = "Livingroom"
    show screen navroom_m
    show screen daytime
    call screen livingroom_hm1
    jump expression _return + "_livingroom_hm1"

screen livingroom_hm1:
    zorder 0
    modal True
    use bgsky
    add "hm1/livingroom/livingroom_hm1.png"
    if (time == 10) or (time == 12) or (time == 22):
        imagebutton auto "hm1/livingroom/m_livingroom_hm1_%s.png" xpos 1325 ypos 704 focus_mask True action Return("m")
    if (time == 11) or (time == 13) or (time == 18) or (time == 19):
        imagebutton auto "hm1/livingroom/bs_livingroom_hm1_%s.png" xpos 1324 ypos 697 focus_mask True action Return("bs")


label bs_livingroom_hm1:
    scene bgsky
    show bs_livingroom_diag0_hm1
    mc "Ciao [bsname]. Posso sedermi?"
    call bs_0_10
    call screen livingbackscreen
    jump expression _return + "_hm1"


label m_livingroom_hm1:
    scene bgsky
    show m_livingroom_diag0_hm1
    mc "Hey [mname]. Posso farti compagnia?"
    call bs_0_10
    call screen livingbackscreen
    jump expression _return + "_hm1"

My code now is right? it work but i want learn how do a right one not a working one simply :)
 

Cohibozz

Member
Aug 14, 2018
126
27
one last (for now) info.

if i use screen bgsky in a screen it work good to show sky different for different time of the day.

if i use bg in label with scene bgsky it show a grey bg image
 

Cohibozz

Member
Aug 14, 2018
126
27
this is my bgsky screen:

Code:
screen bgsky:
    tag bgsky
    if 4 < time < 18:
        add "cielo sereno giorno.png"
    elif 17 < time < 21:
        add "cielo sereno sera.png"
    else:
        add "black"
 

Cohibozz

Member
Aug 14, 2018
126
27
i've another strange (for me) problem.
in c_bedroom my time check don't work (possible an idiot error but i can't find it) and always show night version of the room

and the other problem is that i don't know how an animation work...i've tried to do one but not work...
my code is:
Code:
label c_bedroom_hm2:
    $whereim = "Bedroom {0}".format(c)
    show screen navroom_u
    show screen daytime
    if (1 < time < 7) :
        call screen c_bedroom_hm2
    else :
        call screen c_bedroom_sleep_hm2
    jump expression _return + "_hm2"


screen c_bedroom_sleep_hm2:
    zorder 0
    modal True
    use bgsky
    add "hm2/c_room/c_bed_sleep_bedroom_hm2.png"
    imagebutton auto "hm2/c_room/c_bed_sleep_bedroom_hm2_%s.png" xpos 538 ypos 590 focus_mask True action Return("c_bed_sleep_bedroom")

screen c_bedroom_hm2:
    zorder 0
    modal True
    use bgsky
    add "hm2/c_room/c_bedroom_hm2.png"
    imagebutton auto "arrow_%s.png" xalign 0.5 yalign 1.0 focus_mask True action Return("c_bedroom")



label c_bed_sleep_bedroom_hm2:
    scene c_bed_bedroom_hm2
    mc "Dorme profondamente..."
    menu c_sleep_010:
        "Guarda meglio":
            "ok tiriamo un po piu in giu la coperta..."
            $nightshow = True
        "Lasciala riposare e vai via":
            "vado a disturbare qualcun altro."
            jump c_bedroom_hm2
    call screen c_bed_bedroom_hm2
    jump expression _return + "_hm2"

screen c_bed_bedroom_hm2:
    if nightshow == True :
        $nightshow = False
        add "c_sleep_010_show"
        add "hm2/c_room/c_bed_sleep_peek7_bedroom_hm2.png"
    else:
        add "hm2/c_room/c_bed_bedroom_hm2.png"
#inserire cose da fare con il letto
    imagebutton auto "arrow_%s.png" xalign 0.5 yalign 1.0 focus_mask True action Return("c_bedroom")

image c_sleep_010_show:
    "hm2/c_room/c_bed_sleep_peek1_bedroom_hm2.png"
    1.5
    "hm2/c_room/c_bed_sleep_peek2_bedroom_hm2.png"
    1.5
    "hm2/c_room/c_bed_sleep_peek3_bedroom_hm2.png"
    1.5
    "hm2/c_room/c_bed_sleep_peek4_bedroom_hm2.png"
    1.5
    "hm2/c_room/c_bed_sleep_peek5_bedroom_hm2.png"
    1.5
    "hm2/c_room/c_bed_sleep_peek6_bedroom_hm2.png"
    1.5
    "hm2/c_room/c_bed_sleep_peek7_bedroom_hm2.png"
    1.5
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,971
16,229
Sorry, i had a rude week-end with really few of free time.

My code now is right? it work but i want learn how do a right one not a working one simply :)
I'll not say that it's right, because it would need many testing, but I didn't see errors in the code.

if i use screen bgsky in a screen it work good to show sky different for different time of the day.

if i use bg in label with scene bgsky it show a grey bg image
The statement expect a displayable, what isn't a screen. If you want to use it directly with scene, you need to define an , either , or with the and possibly a .
In this particular case, only the image statement can do it, because you need to dynamically build the image to reflect the time passing. For this, you need to use the displayable:
Code:
image = ConditionSwitch( "4 < time < 18", "cielo sereno giorno.png",
     "17 < time < 21", "cielo sereno sera.png",
     "True", "black" )
Note: The last choice is the "default" one.