Hide textbox, character images while inventory/stat screen is shown

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
GSoda
Newbie
Posts: 2
Joined: Thu Mar 22, 2018 2:37 pm
Contact:

Hide textbox, character images while inventory/stat screen is shown

#1 Post by GSoda »

Hello and apologies if a similar question was already answered. I am new and the board search always times out on me.

My code is as follows:

Code: Select all

default show_stats = False
default show_contacts = False
default show_test = True

screen my_stats():    
    imagebutton auto "mobile_%s.png" at topright action ToggleVariable("show_stats")
    if show_stats:
        frame:
            background "Misc/phone.png"
            xpos .4
            hbox:
                yoffset 50
                text "POOO"
                textbutton "Contacts" action ToggleVariable("show_contacts")
                if show_contacts:
                    frame:
                        hbox:
                            text "TEST"
                            if show_test:
                                image("button_idle.png")
                            
                text "mooo"
What it is supposed to do is place an imagebutton in the topright corner of my screen which upon clicking shows a stat screen that looks like a mobile phone. The plan is to have three pages with stats, contacts, and messages.

The screen comes up as planed, but the problem is that I also want the game to hide the textbox and any character sprites currently displayed when the mobile screen comes up, which it doesn't do currently. Clicking anywhere that isn't a text/imagebutton also advances the game which I also do not want.

Does anyone have an idea how I could achieve this?

DannX
Regular
Posts: 99
Joined: Mon Mar 12, 2018 11:15 am
Contact:

Re: Hide textbox, character images while inventory/stat screen is shown

#2 Post by DannX »

There are possibly other ways to do this, but you can use two screens, one to show the phone button, and different screens to show the stats and other menus, that can be invoked by that button with the ShowMenu screen action.

Code: Select all

screen phone_button():

    textbutton "My Stats" action ShowMenu('phone_menu')
    
screen phone_menu():
    #Show the player's stats
    text "Player's stats here"
        
    textbutton "Return" yalign .5 action Return()
        
label start:
    show screen phone_button #show the button screen
    
    "Test"
    
    return


ShowMenu hides everything before showing the screen you're passing it, and stops the game from advancing until you exit from it. Always remember to add a button to that screen so the player can exit.

EDIT: It doesn't seem to hide character sprites. Hmm... I'll have to tinker with this a bit more.

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: Hide textbox, character images while inventory/stat screen is shown

#3 Post by Remix »

Code: Select all

init python:
    config.menu_clear_layers.append('master')
Should clear the 'master' layer when doing ShowMenu... Alternatively (as it might clear backgrounds too) move the sprites to a named layer and add that to config clear
Frameworks & Scriptlets:

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3794
Joined: Mon Dec 14, 2015 5:05 am
itch: Imperf3kt
Location: Your monitor
Contact:

Re: Hide textbox, character images while inventory/stat screen is shown

#4 Post by Imperf3kt »

To stop the game progressing while in your inventory screen, add

Code: Select all

    modal True
Near the top of the screen.
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor

Twitter

GSoda
Newbie
Posts: 2
Joined: Thu Mar 22, 2018 2:37 pm
Contact:

Re: Hide textbox, character images while inventory/stat screen is shown

#5 Post by GSoda »

Thanks to everyone! It now works like I want it to :)

Post Reply

Who is online

Users browsing this forum: Dark79, Google [Bot]