Ren'Py Coding Assistance - Animated Background with Screen

Xavster

Well-Known Member
Game Developer
Mar 27, 2018
1,249
7,625
Currently coding the next version of my VN and need a bit of assistance in tweaking my code to get following section to work.
cal_001.jpg
The above is actually an animation with a screen on the upper left. Currently it functions and I am able to switch between various animations via the buttons, however there are a couple of significant issues to overcome.
1) I can't get the screen to stay on screen without the with Pause (20) command.
2) If you click anywhere but on the screen buttons the screen disappears.

I'm hoping it's just a minor tweak to my code as listed below. ;)
Label:
Python:
label lia_lewd:
    scene black
    while lewd_pos != "exit":
        if lewd_pos == "kiss":
            play movie "pcrclak1dy.webm" loop
            show movie
            $ lewd_excite += 10
            show screen lia_lewd_screen
            with Pause (20)
        elif lewd_pos == "grind":
            play movie "pcrclag3o.webm" loop
            show movie
            $ lewd_excite += 10
            show screen lia_lewd_screen
            with Pause (20)
        else:
            ""
    stop movie
    hide screen lia_lewd_screen
    $ lewd_pos = "kiss"
    $ lewd_excite = 0
    jump room_cap
Screen:
Python:
screen lia_lewd_screen:
    zorder 200
    hbox:
        xpos 0.02
        ypos 0.05
        xanchor 0.0
        yanchor 0.0
        spacing 10
        vbar:
            value AnimatedValue(lewd_excite, 100, 1.0)
            ymaximum 210
            xsize 10
        vbox:
            image "l_lia.webp"
        vbox:
            spacing 5
            imagebutton auto "i_exit_%s.png" action [SetVariable("lewd_pos", "exit"), Jump("lia_lewd")]
            imagebutton auto "i_kiss_%s.png" action [SetVariable("lewd_pos", "kiss"), Jump("lia_lewd")]
            imagebutton auto "i_grind_%s.png" action [SetVariable("lewd_pos", "grind"), Jump("lia_lewd")]
 

recreation

pure evil!
Respected User
Game Developer
Jun 10, 2018
6,327
22,773
You could make the labe "lia_lewd" a screen and call it like the other screen, then instead of show screen lia_lewd_screen, you'd have to use screen lia_lewd_screen, that would stop the dialogue from advancing.

There is some other way around, but I don't remember it at the moment, so maybe wait for another answer.
 
  • Like
Reactions: Xavster

Porcus Dev

Engaged Member
Game Developer
Oct 12, 2017
2,582
4,705
If you use "modal True" you prevent clicking outside the screen:
Python:
screen lia_lewd_screen:
    modal True
    zorder 200
    hbox:
        xpos 0.02
        ypos 0.05
        xanchor 0.0
        yanchor 0.0
        spacing 10
        vbar:
            value AnimatedValue(lewd_excite, 100, 1.0)
            ymaximum 210
            xsize 10
        vbox:
            image "l_lia.webp"
        vbox:
            spacing 5
            imagebutton auto "i_exit_%s.png" action [SetVariable("lewd_pos", "exit"), Jump("lia_lewd")]
            imagebutton auto "i_kiss_%s.png" action [SetVariable("lewd_pos", "kiss"), Jump("lia_lewd")]
            imagebutton auto "i_grind_%s.png" action [SetVariable("lewd_pos", "grind"), Jump("lia_lewd")]
 

Porcus Dev

Engaged Member
Game Developer
Oct 12, 2017
2,582
4,705
And to keep the "screen" on screen, simply use "pause":
Python:
label lia_lewd:
    scene black
    while lewd_pos != "exit":
        if lewd_pos == "kiss":
            play movie "pcrclak1dy.webm" loop
            show movie
            $ lewd_excite += 10
            show screen lia_lewd_screen
            pause
        elif lewd_pos == "grind":
            play movie "pcrclag3o.webm" loop
            show movie
            $ lewd_excite += 10
            show screen lia_lewd_screen
            pause
            "...."   ### Show dialogue if you want
        else:
            ""
    stop movie
    hide screen lia_lewd_screen
    $ lewd_pos = "kiss"
    $ lewd_excite = 0
    jump room_cap
 
  • Like
Reactions: Xavster

Porcus Dev

Engaged Member
Game Developer
Oct 12, 2017
2,582
4,705
But bear in mind that if you want to show dialogue you can't use "modal True", as this prevents the player from being able to click to advance and have the dialogue shown; and with "modal True" you will also need an "exit" button to leave the screen and continue with the game... it all depends on how you have planned it.
 
  • Like
Reactions: Xavster

the66

beware, the germans are cumming
Modder
Donor
Respected User
Jan 27, 2017
7,808
24,388
totally untested
Python:
image pcrclak1dy = Movie(play="pcrclak1dy.webm")
image pcrclag3o = Movie(play="pcrclag3o.webm")

screen lia_lewd_screen:
    default lewd_pos = "pcrclak1dy"
    default lewd_excite = 0
    default end = False

    if end:
        timer 5. action Return(True)

    add lewd_pos

    hbox:
        xpos 0.02
        ypos 0.05
        xanchor 0.0
        yanchor 0.0
        spacing 10
        vbar:
            value AnimatedValue(lewd_excite, 100, 1.0)
            ymaximum 210
            xsize 10
        vbox:
            image "l_lia.webp"
        vbox:
            spacing 5
            imagebutton auto "i_exit_%s.png" action Return(False)
            imagebutton auto "i_kiss_%s.png" action [SetScreenVariable("lewd_pos", "pcrclak1dy"), SetScreenVariable("lewd_excite", lewd_excite + 10), If(lewd_excite >= 100, SetScreenVariable("end", True))]
            imagebutton auto "i_grind_%s.png" action [SetScreenVariable("lewd_pos", "pcrclag3o"), SetScreenVariable("lewd_excite", lewd_excite + 10), If(lewd_excite >= 100, SetScreenVariable("end", True))]

label start:
    $ rv = renpy.call_screen("lia_lewd_screen")
    "[rv]"
    return
 
  • Like
Reactions: Xavster

Xavster

Well-Known Member
Game Developer
Mar 27, 2018
1,249
7,625
Thanks for all of the replies. (y)

As I actually have a significant number of related animations (18 off) and want to have various checks to change dialogue / vary screen / change animation, I am going to stay with the split screen / label alternative. Hence I have supplemented my code using the modal True and pause commands. Whilst the modal True command doesn't allow me to advance text, I can still have a single line of text if I place before the pause command.

To the66, whilst your way may indeed be better, it's a little out of my comfort zone at this time. Hence I'll stick with keeping the intelligence within the label at this point.
 

Porcus Dev

Engaged Member
Game Developer
Oct 12, 2017
2,582
4,705
Whilst the modal True command doesn't allow me to advance text, I can still have a single line of text if I place before the pause command.
Not tested, maybe can help with dialogue...

Python:
default actmodal == False   ### False by default

screen lia_lewd_screen:
    if actmodal == True:  ### A conditional to activate or not "modal True"
        modal True
    zorder 200
    hbox:
        xpos 0.02
        ypos 0.05
        xanchor 0.0
        yanchor 0.0
        spacing 10
        vbar:
            value AnimatedValue(lewd_excite, 100, 1.0)
            ymaximum 210
            xsize 10
        vbox:
            image "l_lia.webp"
        vbox:
            spacing 5
            imagebutton auto "i_exit_%s.png" action [SetVariable("lewd_pos", "exit"), Jump("lia_lewd")]
            imagebutton auto "i_kiss_%s.png" action [SetVariable("lewd_pos", "kiss"), Jump("lia_lewd")]
            imagebutton auto "i_grind_%s.png" action [SetVariable("lewd_pos", "grind"), Jump("lia_lewd")]





label lia_lewd:
    scene black
    while lewd_pos != "exit":
        if lewd_pos == "kiss":
           "......"

        elif lewd_pos == "grind":
            play movie "pcrclag3o.webm" loop
            show movie
            $ lewd_excite += 10
            $ actmodal = False  ### "modal True" disabled, so you can clic and see the dialogue
            show screen lia_lewd_screen
            "...."   ### dialogue 1
            "...."   ### dialogue 2
            pause  ### pause between dialogue if you want
            "...."   ### dialogue 3
            "...."   ### dialogue 4
            $ actmodal = True
            show screen lia_lewd_screen   ### I'm not sure if this is the right command to show the screen again, but this time the "modal True" will be activated
           ### maybe, instead of "show screen ....", you need to use: renpy.restart_interaction() 
            pause
        else:
            ""
    stop movie
    hide screen lia_lewd_screen
    $ lewd_pos = "kiss"
    $ lewd_excite = 0
    jump room_cap
I hope it works for you... although I'm sure there's a more elegant way to do the same :p

PS: Even, if you're interested, it could be programmed so that the dialogue appears only the first time each animation is shown... you know, reading the same thing each time can be tiresome for the player, lol :LOL:
 
  • Like
Reactions: Xavster

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,957
16,191
Whilst the modal True command doesn't allow me to advance text, I can still have a single line of text if I place before the pause command.
You can also display the screen as overlay with . It will stay on display while letting you continue to display dialog lines.

Python:
init python:
    # Define the screen as overlay
    config.overlay_screens.append( "lia_lewd_screen" )

# By default the overlay isn't shown
default lewdOverlay = False

label lia_lewd:
    scene black
    while lewd_pos != "exit":
        if lewd_pos == "kiss":
            play movie "pcrclak1dy.webm" loop
            show movie
            $ lewd_excite += 10
            # Enable the overlay.
            $ lewdOverlay = True
            pause 20
            # Disable it.
            $ lewdOverlay = False
[...]


label whatever:
    play movie "anothermovie.webm" loop
    show movie
    # Enable the overlay.
    $ lewdOverlay = True
    # Continue the scene.
    "Some dialog line"
    "because the action didn't stopped"
    "now it's the end of the movie"
    # Disable the overlay.
    $ lewdOverlay = False
    stop movie

screen lia_lewd_screen():
    # It's a screen property and not a screen statement, it
    # need to be defined before the /if/ clause.
    zorder 200

    # Display only is the overlay is enabled.
    if lewdOverlay is True:
        hbox:
            xpos 0.02
            ypos 0.05
            xanchor 0.0
            [...]
 

Xavster

Well-Known Member
Game Developer
Mar 27, 2018
1,249
7,625
Thanks for the additional contribution. I will keep the methods in mind should I wish to append additional lines of dialogue for each animation. At this point I think having just a single line of dialogue should be sufficient for my needs. It should keep the code a little simpler, which I am always in favour of.

To clarify what I am doing, the scene enables the progression of a romantic encounter where you can change positions and also the excitement level increases. The animation changes based upon excitement level and position. By having the excitement separated from the position, I can customise the dialogue to either or an interaction of both. Hence if you take things too fast, it can be "Hey, a little more foreplay would be nice".