How to still show screen when calling label in new context (point and click interface)?

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
biscuit
Newbie
Posts: 4
Joined: Mon Jan 06, 2020 12:25 pm
Contact:

How to still show screen when calling label in new context (point and click interface)?

#1 Post by biscuit »

Hi everyone!

I'm trying to create a simple point-and-click-interface, where the player can click on various objects and see the main characters thoughts about them. When clicking on an object (like a carpet) I want to carpet to still be shown on screen, while the dialogue about the carpet should steal the full focus of the GUI (the player should not be able to click on any image buttons before the dialogue is done). I'm probably making some silly misstake - but I can't get this to work.

My test code looks like this:

Code: Select all

screen room():
    imagebutton:
        xpos 650
        ypos 322
        xanchor 0.5
        yanchor 0.5
        idle "carpet.png"
        hover "carpet_hover.png"
        tooltip "A strange carpet."
        action Jump("look_at_carpet")
        
    $ tooltip = GetTooltip()

    if tooltip:
        text "[tooltip]":
            text_align 0.5
            xalign 0.5

label enter_room:
    show bg fire
    play music "audio/eating.ogg"
    
label room_loop:
    show screen room
    $ renpy.pause()
    jump room_loop
   
label look_at_carpet:
    "That's a strange looking carpet."
    "I wonder if I can buy a carpet like that on eBay?"
    window hide
    jump room_loop
I can click the carpet and get the dialog (under the label "look_at_carpet"). But when I see text "That's a strange looking carpet." I can still click the carpet again (or other image buttons on the screen), and I want to the screen to be "locked"/"greyed out" until I've completed the full "look_at_carpet"-block (seen all dialogue).

I can change the line:

Code: Select all

action Jump("look_at_carpet") 
... to:

Code: Select all

ui.callsinnewcontext("look_at_carpet")
... and that makes the dialogue act like I want, but if I do that the imagebutton disappears while the dialogue is displayed (since I left the screen context I guess).

I can think of a few exotic (bad) ways to solve this, but I guess there is a nice straighforward way to get the behaviour I want. I want the dialogue act like when I'm using ui.callsinnewcontext (so I can no longer click or hover any image buttons, and so all clicks anywhere on the screen takes me to the next line in the "look_at_carpet"-block, but I still want the imagebuttons to be shown (since it's strange if objects disappears when looking at them :)).

Thanks a lot in advance!

biscuit
Newbie
Posts: 4
Joined: Mon Jan 06, 2020 12:25 pm
Contact:

Re: How to still show screen when calling label in new context (point and click interface)?

#2 Post by biscuit »

It's of course possible to also add the images to the room itself, like this:

Code: Select all

label room_loop:
    show carpet_hover:
        xpos 650
        ypos 322
        xanchor 0.5
        yanchor 0.5

    show screen room
    $ renpy.pause()
    jump room_loop
If feels a bit dirty, even if there may be a way to create some sort of abstraction layer to hide this. If there's a better solution, I'm very interested. :)

philat
Eileen-Class Veteran
Posts: 1910
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: How to still show screen when calling label in new context (point and click interface)?

#3 Post by philat »

Prob easiest way to do this is wrapping all the interact-able parts of the screen in a variable check so that if the variable is false you can't interact with the screen. Dunno how you have your images set up, I guess.

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot], Google [Bot], Semrush [Bot]