Temporarily hide overlay

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
jasmoe4
Newbie
Posts: 7
Joined: Fri Jun 30, 2017 11:35 pm
Contact:

Temporarily hide overlay

#1 Post by jasmoe4 »

Sorry if this is a simple question.

I am tracking experience points in a small overlay. I'm wanting to occasionally turn it off during game play for specific dialogue purposes (like during a tutorial). I don't know what the best way would be to mark it as hidden.

Here's the code from the init section.

Any thoughts?

Thanks,

Code: Select all

showexperience = True #I'm basically wanting to toggle this.
    experience = 0
    def display_experience():
        if showexperience:
            ui.frame(xpos = 1.0, xanchor = "right",
                     ypos = 0.0, yanchor = "top")
            ui.text("Exp: [experience]")
    config.overlay_functions.append(display_experience)

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

Re: Temporarily hide overlay

#2 Post by philat »

I'm confused. Are you asking how to set showexperience to False?

$ showexperience = False should work fine...?

jasmoe4
Newbie
Posts: 7
Joined: Fri Jun 30, 2017 11:35 pm
Contact:

Re: Temporarily hide overlay

#3 Post by jasmoe4 »

philat wrote:I'm confused. Are you asking how to set showexperience to False?

$ showexperience = False should work fine...?
Essentially yes but I would want to do it within the story itself and not in the initialization section above.

I'm basically wanting to hide the portion of the interface that would otherwise show experience points ( and later on money). When I put the code in as you typed it, seemingly nothing happens. The experience points continue to display.

If I go to the code above the start of the game and change it to false it will turn it off.

I'm trying to create a toggle that I can refer to each time I want to turn it off or back on again.

I don't know if I explained any better this time or not. :-)

User avatar
Remix
Eileen-Class Veteran
Posts: 1628
Joined: Tue May 30, 2017 6:10 am
Completed: None... yet (as I'm still looking for an artist)
Projects: An un-named anime based trainer game
Contact:

Re: Temporarily hide overlay

#4 Post by Remix »

I would advise just using a screen to show the information myself...

screens.rpy

Code: Select all

init python:
    config.overlay_screens.append("stat_bar")

screen stat_bar():
    if stats_visible:
        frame:
            xpos 1.0
            ypos 0.0
            xanchor "right"
            yanchor "top"
            text "Exp: [experience]"
script.rpy

Code: Select all

default stats_visible = False
default experience = 100

label start:
    show screen stat_bar
    "No Stats"
    $ stats_visible = True
    "Shown"
    $ experience += 20
    "Updated"
    $ stats_visible = False
    "Hidden"
Either way, that might get you heading in the right direction
Frameworks & Scriptlets:

Post Reply

Who is online

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