Advice : Try to make screen calling each other and close the defaut say screen

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.
Message
Author
sculpteur
Veteran
Posts: 312
Joined: Fri Nov 17, 2017 6:40 pm
Completed: Apocalypse Lovers
Projects: Apocalypse Lovers
Organization: Awake_Production
Location: France
Discord: https://discord.gg/apocalypse-lovers
Contact:

Advice : Try to make screen calling each other and close the defaut say screen

#1 Post by sculpteur »

Hi,
Iam a noob.

This is my first post so I am also checking the weather around here.

I am trying to make an inventory_button screen to display an inventory_bar screen.
Then, in the inventory_bar screen, there is also a button who is identical (the image) to the one of inventory_button.
When clicked, i want it to close the inventory_bar screen. This is working. But this doesnt close the defaut say screen.
Because the defaut "say" screen and his window dosent have any tag that i can use to replace them.

Some images to give you an idea of what iam trying to make :
Image
Image

There is my code :

Code: Select all

image 0-0-inv-butt-small = "gui/inventory_button.png"
image 0-0-inv-butt-small-hover = "gui/inventory_button_hover.png"
image 0-0-inv-butt-small-insensitive = "gui/inventory_button_insensitive.png"


screen inventory_button:
    modal False
    imagebutton:
        keysym "i"
        xpos 0.806 ypos 0.859
        insensitive "0-0-inv-button-small-insensitive"
        idle "0-0-inv-button-small"
        hover "0-0-inv-button-small-hover"
        action Show("inventory_bar")  # <--- Here, I can solve my probleme by writing this : action ShowMenu("inventory_bar") 
        					     # but after the inventory_bar screen is displayed, the game is stuck until i hit escape.

screen inventory_bar:
    modal False
    tag window
    image "gui/Inventory open_bar.png":
            xpos 0.0 ypos 0.77
    imagebutton:
        xpos 0.806 ypos 0.859
        idle "0-0-inv-button-small"
        hover "0-0-inv-button-small-hover"
        action Hide("inventory_bar") # <--- Here, i would like to HIDE the default "say" screen and window with the name of the speaker and everything.
I've already check online but i didn't find (on google, on renpy documentation, etc) a way to hide the defaut "say(who, what)" window.
Of course I know how to hide it in my script labels with this command : window hide.
But saddly this command doesnt work inside a screen(). So i would like to know if it's at least possible.

So if you could help me fixe this it will be great !

PS : And by the way, if you think my way of coding this thing suck, do not hesistate to tell me (as long as you suggest something better ^^).

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: Advice : Try to make screen calling each other and close the defaut say screen

#2 Post by Remix »

https://www.renpy.org/doc/html/dialogue ... management

Function( _window_hide, True )
Function( _window_show, False )

True/False for transition or not

Remember to put multiple actions in list braces ... action [ Function(...), Show(...) ] ... I guess you know that though
Frameworks & Scriptlets:

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: Advice : Try to make screen calling each other and close the defaut say screen

#3 Post by Remix »

Do you really want the 'say' window (which includes the name) to disappear each time though?
Perhaps it might fell more fluid to just *steal* the namebox when you want it by tweaking the say screen? (or is your arrow meant to be pointing at the dialogue window?)

Untested pseudo code...

Code: Select all

default show_inventory = False
screen say(who, what):
    style_prefix "say"

    window:
        id "window"

        if show_inventory:

            use the_inventory_bar_screen
            # probably just a hbox with inventory in it

        elif who is not None:

            window:
                style "namebox"
                text who id "who"

        text what id "what"
        imagebutton ... action ToggleVariable( "show_inventory" ) xpos 1.0 xanchor 1.0
Frameworks & Scriptlets:

sculpteur
Veteran
Posts: 312
Joined: Fri Nov 17, 2017 6:40 pm
Completed: Apocalypse Lovers
Projects: Apocalypse Lovers
Organization: Awake_Production
Location: France
Discord: https://discord.gg/apocalypse-lovers
Contact:

Re: Advice : Try to make screen calling each other and close the defaut say screen

#4 Post by sculpteur »

Incorporating this code in the say screen scared me because i was about to creat a huge inventory systeme so i didn't want to mix it with defaut say screen window.

But in fact this is really good idea because i want my inventory button (the little green bag on the right) to ne displayed or hidden at the same time than the say window (dialog windo and namebox).

But when this little button is press the name of character (namebox) have to disapear and the dialog text box (huge main window for telling the story) will be used to display tooltips and description of each items when hovered in the inventory.

So you solution is really interesting, i got it generally, but i didn't get that part :

Code: Select all

            use the_inventory_bar_screen
            # probably just a hbox with inventory in it
Because :
1 : iam not familiar with the "use" statement in a screen.
2 : i dont know if you recommand me to creat my inventory_bar window here or not.


And i need one more precision on this part :

Code: Select all

imagebutton ... action ToggleVariable( "show_inventory" ) xpos 1.0 xanchor 1.0
So if i understand, I will also have to creat a boolean veriable called show_inventory ?

Thank you

PS : And sorry about my english, this is'nt my native langage.
Image

“He asked me to calm down, close my eyes and be quiet. He explained to me that if I was afraid, the shadow that ran barefoot in the street would feel it. I got scared seeing Jumanji on TV, so let me tell you, we didn't stay hidden for long and had to start running again.”
Jessica's Diary.

sculpteur
Veteran
Posts: 312
Joined: Fri Nov 17, 2017 6:40 pm
Completed: Apocalypse Lovers
Projects: Apocalypse Lovers
Organization: Awake_Production
Location: France
Discord: https://discord.gg/apocalypse-lovers
Contact:

Re: Advice : Try to make screen calling each other and close the defaut say screen

#5 Post by sculpteur »

Nevermind i worked somthing out.

I still DONT UNDERSTAND, the "use" statement. (and didn't find anything online).

But i manage without using it, like this :

in script file:

Code: Select all

$ show_inventory = False
in screen file :

Code: Select all

screen say(who, what):
    style_prefix "say"

    window:
        id "window"

        if show_inventory:
            image "gui/textbox - Inventory open.png":
                xpos 0.0 ypos -0.15

        elif who is not None:

            window:
                style "namebox"
                text who id "who"

        text what id "what"
    imagebutton:
        keysym "i"
        xpos 0.806 ypos 0.859
        insensitive "0-0-inv-butt-small-insensitive"
        idle "0-0-inv-butt-small"
        hover "0-0-inv-butt-small-hover"
        action ToggleVariable( "show_inventory" )


So now, only 2 th ings matter :
1 - If you could still explain me how the "use" statement is soppose to work.
2 - If you could tell me how to untoggle show_inventory boolean if the user click anywhere on the screen and continue with the story. Otherwise the story can continue whitout displaying the name of the characters.
I mean the inventory display should do some kind of pause but the game should resume if the player click anywhere but on the inventory menu.
For doing this iam looking for thi code who is played when the player click and the next image appears, i've heard is called "ctc" (click to continue) but i dont know where i can find it !

Thank you !
Image

“He asked me to calm down, close my eyes and be quiet. He explained to me that if I was afraid, the shadow that ran barefoot in the street would feel it. I got scared seeing Jumanji on TV, so let me tell you, we didn't stay hidden for long and had to start running again.”
Jessica's Diary.

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: Advice : Try to make screen calling each other and close the defaut say screen

#6 Post by Remix »

Ok...

Because you want to hide the dialogue and name area when the inventory appears ( re-using that would be pretty tricky tbh, especially as it couldn't be modal so clicks inside inventory could/would advance dialogue in the background) we cannot really have the Open/Close button inside it...

I would actually advise, similar to your first post and my first reply, place the open/close button as its own screen set as an overlay, using actions therein to hide/show the other parts as needed... a few snippets after some answers...
1 : iam not familiar with the "use" statement in a screen.
Use and Transclude - just ways to include screens inside other screens... worth learning though maybe not needed just here.
So if i understand, I will also have to creat a boolean veriable called show_inventory ?
My snippet did actually have show_inventory set at a default before the screen. The action ToggleVariable basically just toggles it True->False->True etc on each click. It can be used in some scenarios though maybe not here.

Some quick scrap code to give an idea...

Code: Select all

screen inventory_button:
    modal False
    imagebutton:
        keysym "i"
        xpos 0.806 ypos 0.859
        insensitive "0-0-inv-button-small-insensitive"
        idle "0-0-inv-button-small"
        hover "0-0-inv-button-small-hover"
        action If( renpy.get_screen( "inventory_bar" ), 
                       [ Hide( "inventory_bar" ), Function( _window_show, False ) ], # actions If inv bar is showing
                       [ Show("inventory_bar"), Function( _window_hide, True ) ] ) # actions If inv bar not showing

init python:
    config.overlay_screens.append('inventory_button')

screen inventory_bar:
    modal True # to stop dialogue advancing if we click stuff
    grid 3 3:
        for k in range(1,10):
            text "Item [k]"
Because the inventory open/close button is on an overlay layer it *should* (untested) still be clickable above the modal inventory_bar as that is on the screens layer. The open/close button has conditional action that just changes depending if inventory is open already...

Hope that makes sense.
Shout if the modal bit stops the 'close' from working
Frameworks & Scriptlets:

sculpteur
Veteran
Posts: 312
Joined: Fri Nov 17, 2017 6:40 pm
Completed: Apocalypse Lovers
Projects: Apocalypse Lovers
Organization: Awake_Production
Location: France
Discord: https://discord.gg/apocalypse-lovers
Contact:

Re: Advice : Try to make screen calling each other and close the defaut say screen

#7 Post by sculpteur »

Thank you, I think you are right, but this doesnt work. I think this is this part :

Code: Select all

action If( renpy.get_screen( "inventory_bar" )), 
                       [ Hide("inventory_bar" ), Function( _window_show, False ) ], # actions If inv bar is showing
                       [ Show("inventory_bar"), Function( _window_hide, True ) ] # actions If inv bar not showing
What happen :

The inventory button is displayed
The inventory button idle and hover state are working.
But when you click on it nothing happens. There is no error screen which appear, no message. Just nothing.


If the inventory button is displayed even at the very begining of the game.
I think is it due to this

Code: Select all

 init python:
    config.overlay_screens.append('inventory_button')
Because you append it to the list of default overlay screen right ?
But the problem is that it didn't follow the show/hide state of the say window.
I don't want to have the inventory button floating alone on my screen.
I want it to appear only when the say window is shown.
That's why i think i will have to modified the say screen anyway. But the modification will be lighter with you approach i think.
Image

“He asked me to calm down, close my eyes and be quiet. He explained to me that if I was afraid, the shadow that ran barefoot in the street would feel it. I got scared seeing Jumanji on TV, so let me tell you, we didn't stay hidden for long and had to start running again.”
Jessica's Diary.

sculpteur
Veteran
Posts: 312
Joined: Fri Nov 17, 2017 6:40 pm
Completed: Apocalypse Lovers
Projects: Apocalypse Lovers
Organization: Awake_Production
Location: France
Discord: https://discord.gg/apocalypse-lovers
Contact:

Re: Advice : Try to make screen calling each other and close the defaut say screen

#8 Post by sculpteur »

Because you want to hide the dialogue and name area when the inventory appears ( re-using that would be pretty tricky tbh, especially as it couldn't be modal so clicks inside inventory could/would advance dialogue in the background) we cannot really have the Open/Close button inside it...
Just to let you know i dont care if its not modal as long as the inventory_bar is hidden when continuing with the story.
For example, when you press H it's hide the UI to watch your backround image in full screen. But if you click anywere you come back at the same stage you were before hidden the screen. I mean you "click" didn't make the story progress.
Image

“He asked me to calm down, close my eyes and be quiet. He explained to me that if I was afraid, the shadow that ran barefoot in the street would feel it. I got scared seeing Jumanji on TV, so let me tell you, we didn't stay hidden for long and had to start running again.”
Jessica's Diary.

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: Advice : Try to make screen calling each other and close the defaut say screen

#9 Post by Remix »

I had to edit my post and add a closing parenthesis after the actions... )

... Function( _window_hide, True ) ] ) # <--- that ) there is important ... weird it did not error though
Frameworks & Scriptlets:

sculpteur
Veteran
Posts: 312
Joined: Fri Nov 17, 2017 6:40 pm
Completed: Apocalypse Lovers
Projects: Apocalypse Lovers
Organization: Awake_Production
Location: France
Discord: https://discord.gg/apocalypse-lovers
Contact:

Re: Advice : Try to make screen calling each other and close the defaut say screen

#10 Post by sculpteur »

Remix wrote: Sat Nov 18, 2017 9:14 am I had to edit my post and add a closing parenthesis after the actions... )

... Function( _window_hide, True ) ] ) # <--- that ) there is important ... weird it did not error though
It did not error because i saw a missing parenthesis in the first time and i correct it this way :

Code: Select all

        action If( renpy.get_screen( "inventory_bar" )), # <--- Here i had added a ")"  ^^ 
                       [ Hide("inventory_bar" ), Function( _window_show, False )]), # actions If inv bar is showing
                       [ Show("inventory_bar"), Function( _window_hide, True )])
Image

“He asked me to calm down, close my eyes and be quiet. He explained to me that if I was afraid, the shadow that ran barefoot in the street would feel it. I got scared seeing Jumanji on TV, so let me tell you, we didn't stay hidden for long and had to start running again.”
Jessica's Diary.

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: Advice : Try to make screen calling each other and close the defaut say screen

#11 Post by Remix »

I think you will hit game play snags if the inventory is not modal as any click or drag could progress dialogue - I cannot say for sure if hiding the say window stops dialogue advance - if it does, all is good.

If the button is inside the say window though, it too will get hidden when inventory opens, which isn't helpful - hence the option of putting it on an overlay screen even if it means repositioning it relative to the whole area rather than just the say window.

The If( ) action basically does

If( condition, do this if true, do this if false )

Your ) needs removing, just the one at the end needed adding - so the actions are passed
Frameworks & Scriptlets:

sculpteur
Veteran
Posts: 312
Joined: Fri Nov 17, 2017 6:40 pm
Completed: Apocalypse Lovers
Projects: Apocalypse Lovers
Organization: Awake_Production
Location: France
Discord: https://discord.gg/apocalypse-lovers
Contact:

Re: Advice : Try to make screen calling each other and close the defaut say screen

#12 Post by sculpteur »

All right that's good to know.

Saddly like you said :
Shout if the modal bit stops the 'close' from working
There is an error when i click on the inventory button to close it (so the 2nd time).
The first time is working, i have the modal screen showed up.
But when i try to hide it by clicking again on the inventory button he tell me this kind of error :

I'm sorry, but an uncaught exception occurred.

While running game code:
File "renpy/common/00action_other.rpy", line 484, in __call__
rv = self.callable(*self.args, **self.kwargs)
File "renpy/common/000window.rpy", line 60, in _window_show
renpy.with_statement(trans)
Exception: Cannot start an interaction in the middle of an interaction, without creating a new context.
Image

“He asked me to calm down, close my eyes and be quiet. He explained to me that if I was afraid, the shadow that ran barefoot in the street would feel it. I got scared seeing Jumanji on TV, so let me tell you, we didn't stay hidden for long and had to start running again.”
Jessica's Diary.

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: Advice : Try to make screen calling each other and close the defaut say screen

#13 Post by Remix »

What does your open/close button action look like? Is there still a 2nd added ) on the _show_window line? It should end in ], only
Frameworks & Scriptlets:

sculpteur
Veteran
Posts: 312
Joined: Fri Nov 17, 2017 6:40 pm
Completed: Apocalypse Lovers
Projects: Apocalypse Lovers
Organization: Awake_Production
Location: France
Discord: https://discord.gg/apocalypse-lovers
Contact:

Re: Advice : Try to make screen calling each other and close the defaut say screen

#14 Post by sculpteur »

Yep i think the parenthesis are okey, so i dont understand why everything is blocked after i hit the button.
The code look like this :

Code: Select all

screen inventory_button:
    modal False
    imagebutton:
        keysym "i"
        xpos 0.806 ypos 0.859
        insensitive "0-0-inv-butt-small-insensitive"
        idle "0-0-inv-butt-small"
        hover "0-0-inv-butt-small-hover"
        action If( renpy.get_screen( "inventory_bar" ), 
                       [ Hide("inventory_bar" ), Function( _window_show, False )],# actions If inv bar is showing
                       [ Show("inventory_bar"), Function( _window_hide, True )]) # actions If inv bar not showing

init python:
    config.overlay_screens.append('inventory_button')

screen inventory_bar:
    modal False # to stop dialogue advancing if we click stuff
    image "gui/textbox - Inventory open.png":
        xpos 0.0 ypos 0.77
    grid 3 3:
        for k in range(1,10):
            text "Item [k]" 
Image

“He asked me to calm down, close my eyes and be quiet. He explained to me that if I was afraid, the shadow that ran barefoot in the street would feel it. I got scared seeing Jumanji on TV, so let me tell you, we didn't stay hidden for long and had to start running again.”
Jessica's Diary.

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: Advice : Try to make screen calling each other and close the defaut say screen

#15 Post by Remix »

Ouch, that took some messing around to finally get working... it kept refusing to re-show the say dialogue afterwards... anyway...

Code: Select all

screen inventory_button:
    modal False
    fixed:
        imagebutton:
            keysym "i"
            xpos 0.806 ypos 0.859

            # CHANGE THIS 
            auto "gui/trans_button_%s.png"

            action If( renpy.get_screen( "inventory_bar" ), 
                       [ Return() ], # actions If inventory_bar is showing
                       [ ShowMenu( "inventory_bar" ) ] ) # actions If inventory_bar not showing

init python:
    config.overlay_screens.append('inventory_button')

screen inventory_bar:
    modal True

    grid 3 3:
        for k in range(1,10):
            text "Item [k]" 
    use inventory_button
Frameworks & Scriptlets:

Post Reply

Who is online

Users browsing this forum: No registered users