Page 1 of 1

[SOLVED]hide textbutton

Posted: Thu May 09, 2019 9:47 am
by senisanti
Hi friends

I created an image button to make this screen appear below

Code: Select all

screen test_frame():
    frame:
        xpadding 20
        ypadding 10
        xalign 0.10
        yalign 0.08

        vbox:
            text "Characters"
            null height 10
            textbutton "Amelia" action If(renpy.get_screen("amelia01"), Hide("amelia01"), Show("amelia01"))
            textbutton "Jimena" action If(renpy.get_screen("jimena01"), Hide("jimena01"), Show("jimena01"))
            textbutton "Carla" action If(renpy.get_screen("carla01"), Hide("carla01"), Show("carla01"))

As you can see, display a list of characters.
I put this screen before the label start.
My problem is that all the characters in this list are clickable from the beginning of the game
I would like them to appear only at the moment of the story; the moment where I meet the character.

in the renpy documents they talk about a method to make the screens appear but not via an image button

do you know if it is possible to make the button clickable only from a certain point in history?

Re: hide textbutton

Posted: Thu May 09, 2019 9:54 am
by Saa
Instead of putting the If on the button's action, put it outside the buttons:

Code: Select all

screen test_frame():
    frame:
        xpadding 20
        ypadding 10
        xalign 0.10
        yalign 0.08

        vbox:
            text "Characters"
            null height 10
            if renpy.get_screen("amelia01")==True:
                        textbutton "Amelia" action [Hide("amelia01"), Show("amelia01")]
            if renpy.get_screen("jimena01")==True:
                        textbutton "Jimena" action [Hide("jimena01"), Show("jimena01")]
            if renpy.get_screen("carla01")==True:
                        textbutton "Carla" action [Hide("carla01"), Show("carla01")]
If, instead of simply not showing it, you want to make the buttons greyed out:

Code: Select all

screen test_frame():
    frame:
        xpadding 20
        ypadding 10
        xalign 0.10
        yalign 0.08

        vbox:
            text "Characters"
            null height 10
            textbutton "Amelia" action [Hide("amelia01"), Show("amelia01")] sensitive renpy.get_screen("amelia01")==True
            textbutton "Jimena" action [Hide("jimena01"), Show("jimena01")] sensitive renpy.get_screen("jimena01")==True
            textbutton "Carla" action [Hide("carla01"), Show("carla01")] sensitive renpy.get_screen("carla01")==True

Re: hide textbutton

Posted: Thu May 09, 2019 10:05 am
by Matalla
You can setup a variable and set it to True at the point you meet the character.

Code: Select all

"Here you meet Amelia"
$ iknowamelia = True
Then, in the screen...

Code: Select all

if iknowamelia:
    textbutton "Amelia" action Show("amelia01")
Also, you can use this.

Code: Select all

    textbutton "Amelia" [action Show("amelia01"), SensitiveIf(iknowamelia == True)]
The first method would make the button appear only when the condition is true, the second would allow the button to appear, but it would do nothing, unless the condition is true.

Re: hide textbutton

Posted: Thu May 09, 2019 12:32 pm
by senisanti
Matalla, your method don't work
open traceback and .....
File "game/script.rpy", line 97, in prepare
textbutton "Amelia" [action Show("amelia01"), SensitiveIf(iknowamelia == True)]
SyntaxError: invalid syntax (game/script.rpy, line 97)


Saa, how do can i validate true when i meet my character?

Re: hide textbutton

Posted: Thu May 09, 2019 2:40 pm
by Saa
Add the $ iknowamelia like Matalla said, then for the buttons:

Code: Select all

screen test_frame():
    frame:
        xpadding 20
        ypadding 10
        xalign 0.10
        yalign 0.08

        vbox:
            text "Characters"
            null height 10
            textbutton "Amelia" action [Hide("amelia01"), Show("amelia01")] sensitive iknowamelia==True
            textbutton "Jimena" action [Hide("jimena01"), Show("jimena01")] sensitive iknowjimena==True
            textbutton "Carla" action [Hide("carla01"), Show("carla01")] sensitive iknowcarla==True

Re: hide textbutton

Posted: Thu May 09, 2019 8:55 pm
by Matalla
senisanti wrote:
Thu May 09, 2019 12:32 pm
Matalla, your method don't work
open traceback and .....
File "game/script.rpy", line 97, in prepare
textbutton "Amelia" [action Show("amelia01"), SensitiveIf(iknowamelia == True)]
SyntaxError: invalid syntax (game/script.rpy, line 97)


Saa, how do can i validate true when i meet my character?
I use that syntax and it works for me. You can see it in the documentation.
https://www.renpy.org/doc/html/screen_a ... ensitiveIf

Here's a piece of code actually working in my project

Code: Select all

                textbutton "- " + clue.name:
                    action [Deduce(clue), SensitiveIf(triesleft>0)]
It could be because I define my buttons differently, not in one line, I don't know. Also remember to asign a default value (False) to the variable.

Re: hide textbutton

Posted: Fri May 10, 2019 2:34 am
by senisanti
Okay thank you, I think my problem was CAP, I have to learn the importance of the capital key for some words

but I still have a very big problem.
the hide doesnt work

this is what I did:

textbutton "Amelia" action [Hide("amelia01"), Show("amelia01")] sensitive iknowamelia==True

default iknowamelia = False

somewhere in story:

$ iknowamelia = True


at the beginning of the game the name amelia is grayed out, I can't click it, when I meet amelia the button becomes clickable, everything works so far, but if I click on amelia, the frame with the image of amelia and its stats appears but I can't close it anymore, it remains there in the middle of the screen, I click on amelia nothing happens, if I open another character it also remains open

something is missing between action and [hide
because if I reverse hide and show I can no longer open the character frame

Re: hide textbutton

Posted: Fri May 10, 2019 4:56 am
by Matalla
You should put the code of the screen amelia01 if you want some helpful answers. For closing the screen you'll need something there to tell the screen to go away; a button, a timer, etc.

If you want the screen to hide when other screens of the same kind appear, you can use a tag.
https://www.renpy.org/doc/html/screens. ... -statement

Also, I don't know why you hide and show the screen with the button, just show would be enough. By putting the two, only the latter would be visible. So, of course, if the last one is hide, you won't see the screen. You just tell it to hide.

If you want to use the same button to show and hide the screen, you'll need a completely different approach.

Re: hide textbutton

Posted: Fri May 10, 2019 7:19 am
by senisanti
yes I want to use the same button to show and hide the document

before I used the method to display a button on my documents
but you showed me this technique to show/hide the list of characters because it's easier than using the display button method to close.

now I can use the close button on my frame but I would prefer to continue with the same method

Yes, I'll put all the code so you can see better what's being done.

Code: Select all

 screen buttonchara():
    imagebutton auto "icon/buttonchara_%s.png" action If(renpy.get_screen("test_frame"), Hide("test_frame"), Show("test_frame")) align (0.03, 0.02)

screen test_frame():
    frame:
        xpadding 20
        ypadding 10
        xalign 0.10
        yalign 0.08

        vbox:
            text "Characters"
            null height 10
            textbutton "Amelia" action [Hide("amelia01"), Show("amelia01")] sensitive iknowamelia==True
            textbutton "Jimena" action [Hide("jimena01"), Show("jimena01")] sensitive iknowjimena==True
            textbutton "Carla" action [Hide("carla01"), Show("carla01")] sensitive iknowcarla==True

default iknowamelia = False
default iknowjimena = False
default iknowcarla = False

label start:
    show screen buttonoff
    show screen buttonchara 
with this code everything works fine, except the hide, I can't hide the document.
you give a solution with the button close apparent in the document, I can do that but I want"prefer" to continue as I started, if there is a solution for the hide to work

I tried to add a second hide

Code: Select all

 textbutton "Amelia" action [Hide("amelia01"), Show("amelia01"), Hide("amelia01")] sensitive iknowamelia==True 
pls don't make fun of me. :)
that don't work

I try this :

Code: Select all

 textbutton "Amelia" action [Show("amelia01"), Hide("amelia01")] sensitive iknowamelia==True 
so I can no longer display the document

I hope it's understable and that you know how to allow me to hide the document using the same button as to make it appear

Re: hide textbutton

Posted: Fri May 10, 2019 8:34 pm
by Matalla
You still did't show the code for any character's screen (amelia01, jimena01, etc.) as I asked.

I told you that putting more show/hide actions wouldn't solve a thing, as you'll only see the result of the last one, and you still did it.

It's difficult to help you if you don't listen.

I'll post a simple code to show/hide a screen with a button, and an example of how to tag a group of screens to hide the others when shown.

Code: Select all

    if renpy.get_screen("amelia01"):
        textbutton "Amelia" action Hide("amelia01") sensitive iknowamelia==True # Assuming this code is ok; as I said, I do it differently
    else:
        textbutton "Amelia" action Show("amelia01") sensitive iknowamelia==True

Code: Select all

screen amelia01():
    tag girls
    # The rest of your screen's code here
    
screen jimena01():
    tag girls
    # The rest of your screen's code here

# Do the same with all the character's screen
I did not test it, but it should work. Good luck.

Re: hide textbutton

Posted: Sat May 11, 2019 2:38 am
by senisanti
It still doesn't work, I still can't hide my character's screen.

Code: Select all

 screen buttonchara():
    imagebutton auto "icon/buttonchara_%s.png" action If(renpy.get_screen("test_frame"), Hide("test_frame"), Show("test_frame")) align (0.03, 0.02) 

Code: Select all

 
screen test_frame():
    frame:
        xpadding 20
        ypadding 10
        xalign 0.10
        yalign 0.08

        vbox:
            text "Characters"
            null height 10
            if renpy.get_screen("amelia01"):
                textbutton "Yuki" action Hide("yuki01") sensitive iknowyuki==True
            else:
                textbutton "Yuki" action Show("yuki01") sensitive iknowyuki==True 
the show code is correct because I manage to display the characters' screens, I think then that the hide code is also correct, if I'm not made of mistakes, I checked several times
maybe this method can't join the two show/hide and it would be better to use your way of doing things ?

Code: Select all

 
screen yuki01():
    tag girls
    frame:
        image "yuki01"
        align(0.40,0.09)
        xysize(566, 566)
        vbox:
            style_prefix "yourstatstyle"
            align(0.70, 0.22)
            null height 10
            text "Years Old: [yukyo]"
            null height 10
            text "Work: [yukwork]"
            null height 10
            text "Team Stats: [yuklikeelpi]"
            null height 10
            text "Passtime: [yukpasstime]" 

style yourstatstyle_text is gui_text
style yourstatstyle_text:
   color "#990000"

default yukyo = 22
default yukwork = "School"
default yukts= 10
default yukpasstime = "Manga" 
Now I added the character's screen :)

Re: hide textbutton

Posted: Sat May 11, 2019 3:08 am
by Matalla
senisanti wrote:
Sat May 11, 2019 2:38 am
It still doesn't work, I still can't hide my character's screen.

Code: Select all

 screen buttonchara():
    imagebutton auto "icon/buttonchara_%s.png" action If(renpy.get_screen("test_frame"), Hide("test_frame"), Show("test_frame")) align (0.03, 0.02) 
It doesn't work because it's the same mess as it was before. Now that you have a working method for hiding and showing screens with a button you should be able to apply it here.

Hint: it's the same as the one for the characters.

And hiding and showing the same screen in the same chain of actions still doesn't do what you think, as I told you before.

Re: hide textbutton

Posted: Sat May 11, 2019 4:00 am
by senisanti

Code: Select all

  screen buttonchara():
    imagebutton auto "icon/buttonchara_%s.png" action If(renpy.get_screen("test_frame"), Hide("test_frame"), Show("test_frame")) align (0.03, 0.02) 
this button works very well, this one displays the list of characters

in the character list I can click on a name and make this character appear but not make it disappear

Re: hide textbutton

Posted: Sat May 11, 2019 4:27 am
by Matalla
senisanti wrote:
Sat May 11, 2019 4:00 am

in the character list I can click on a name and make this character appear but not make it disappear

Code: Select all

 
            if renpy.get_screen("amelia01"):
                textbutton "Yuki" action Hide("yuki01") sensitive iknowyuki==True
            else:
                textbutton "Yuki" action Show("yuki01") sensitive iknowyuki==True 
Obviously, if you are dealing with hiding or showing the screen yuki01, it makes little sense checking if the screen amelia01 is present or not. Use logic thinking to know what you are asking the code to do. If you just throw pieces of code around, you' won't even know what's wrong.

Re: hide textbutton

Posted: Sat May 11, 2019 4:57 am
by senisanti
ah oops....

with the right image it works better it seems because now all the code works :)

thank you very much and thank you for your patience, my fingers and head arent always agree unfortunately