Another way to make Show,Hide in one button only?(SOLVED)

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
User avatar
bimb2212
Newbie
Posts: 19
Joined: Wed Jul 30, 2014 10:15 am
Contact:

Another way to make Show,Hide in one button only?(SOLVED)

#1 Post by bimb2212 »

This is my code, but it doesn't good. If I click on outside of inven_screen, and when the choices menu appear, it won't hide the inven_screen (only say screen hide). So, that can make look really buggy.

Code: Select all

if inven_button == 1:
    textbutton ("Inventory") action [Show("inven_screen"), SetVariable("inven_button", 0)] xminimum 115 yminimum 55 
if inven_button == 0:
    textbutton ("Inventory") action [Hide("inven_screen"), SetVariable("inven_button", 1)] xminimum 115 yminimum 55 
Anyone know the quickest way to make a button that contain both show and hide screen without making new "close" button to hide the screen?
Last edited by bimb2212 on Fri Oct 31, 2014 3:34 pm, edited 1 time in total.

User avatar
Alex
Lemma-Class Veteran
Posts: 3096
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: Are there another ways to make Show,Hide in one button o

#2 Post by Alex »

If you want player to be able to interact with the screen only (clicking outside it won't progress the game) then just set the modal parameter to True (and don't forget to make the close button for this screen).
To make one button show and hide the screen you can use such an action

Code: Select all

textbutton "Show/Hide" action If(renpy.get_screen("inven_screen"), true=Hide("inven_screen"), false=Show("inven_screen"))
http://www.renpy.org/doc/html/screens.h ... age-syntax
http://www.renpy.org/doc/html/screen_ac ... er-actions
http://www.renpy.org/doc/html/screen_py ... get_screen

User avatar
bimb2212
Newbie
Posts: 19
Joined: Wed Jul 30, 2014 10:15 am
Contact:

Re: Are there another ways to make Show,Hide in one button o

#3 Post by bimb2212 »

Alex wrote:If you want player to be able to interact with the screen only (clicking outside it won't progress the game) then just set the modal parameter to True (and don't forget to make the close button for this screen).
To make one button show and hide the screen you can use such an action

Code: Select all

textbutton "Show/Hide" action If(renpy.get_screen("inven_screen"), true=Hide("inven_screen"), false=Show("inven_screen"))
http://www.renpy.org/doc/html/screens.h ... age-syntax
http://www.renpy.org/doc/html/screen_ac ... er-actions
http://www.renpy.org/doc/html/screen_py ... get_screen
I know modal = True, but if use Modal, we need to create another button to hide it.
Omg, this code is what I'm looking for because it is sorter, but still have one problem as my code that if we didn't use modal = True, it will appear throughout Choice screen. And it work the same as my code
But I add ShowTransient to both of it, your code work perfect than mine:

Code: Select all

textbutton "Inventory" action If(renpy.get_screen("inven_screen"), true=Hide("inven_screen"), false=ShowTransient("inven_screen"))
Compare with my code:

Code: Select all

if inven_button == 1:
    textbutton ("Inventory") action [ShowTransient("inven_screen"), SetVariable("inven_button", 0)]          #<==== Show changed to ShowTransient
if inven_button == 0:
    textbutton ("Inventory") action [Hide("inven_screen"), SetVariable("inven_button", 1)]
Problem of my code for secondary tried was: If the inventory shows up, and click outside it, it will auto hide and won't progress the game. But after that, we need to click 2 time at inventory button, and it shows again(as when clicked outside, inven_button didn't change value to 1, so we need click on it 1 more time before click it again to show inventory)

Your code with ShowTransient: just click outside inventory's screen 1 times, it hides, and click 1 time inventory's button, it shows again (not click 2 time, someone may think that is laggy).

It's just a minor problem, seems not much ppl use the code like me. But really thanks for your help!!

Post Reply

Who is online

Users browsing this forum: Google [Bot]