Is that possible to hide/unhide textbutton?
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.
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.
Is that possible to hide/unhide textbutton?
So, I want to hide a single textbutton when I click on it, but I don't know how! If I hide screens I will hide all buttons, while I wanna hide just one button that is the one clicked
Something like: when click on the button "open" it dissappear and another texbutton named "close" appears
Something like: when click on the button "open" it dissappear and another texbutton named "close" appears
-
- Miko-Class Veteran
- Posts: 793
- Joined: Fri Feb 09, 2018 12:05 am
- Location: Canada
- Contact:
Re: Is that possible to hide/unhide textbutton?
something like this.. this is what I'm using but I got from someone else I'm just using it
Code: Select all
init 1:
$ mod_show = False
$ mod_button_show = True
screen cheat:
if mod_button_show:
if renpy.loadable("cheatmod.rpy"):
if mod_show == False:
imagebutton xalign 0.10 ypos 0.02:
idle ("enter_mod_idle")
hover ("enter_mod_hover")
action [ Show("more_cheats"), SetVariable("mod_show", True)]
else:
imagebutton xalign 0.10 ypos 0.02:
idle ("exit_mod_idle")
hover ("exit_mod_hover")
if mod_show == True:
action [ Hide("more_cheats"), SetVariable("mod_show", False)]
style show_mod_button:
size 42
#bold True
color "#1DDB16" # E60000
hover_color "#d94c3a"
outlines [(3, "#222222", 0, 0)]
style hide_mod_button:
size 42
#bold True
color "#E60000" # E60000
hover_color "#d94c3a"
outlines [(3, "#222222", 0, 0)]
style ds_mod_style_close_button:
size 40
#bold True
color "#00589E" # E60000
hover_color "#E60000"
outlines [(3, "#000", 0,0)]
style hover_color_buttons:
size 35
hover_color "#d94c3a"
style ds_mod_style:
bold True
color "#00589E" # E60000
hover_color "#c184ff"
outlines [(3, "#000", 0,0)]
style ds_mod_style_red:
bold True
color "#E60000" # E60000
hover_color "#c184ff"
outlines [(3, "#000", 0,0)]
image enter_mod_idle = "images/cheat/hacker_cyber_crime-512.png"
image enter_mod_hover = "images/cheat/hacker_cyber_crime-5123.png"
image exit_mod_idle = "images/cheat/hacker_cyber_crime-512.png"
image exit_mod_hover = "images/cheat/hacker_cyber_crime-5123.png"
Re: Is that possible to hide/unhide textbutton?
It worksss! Thank you rayminator
I never knew I could use conditional statements into a screen
I never knew I could use conditional statements into a screen
Re: Is that possible to hide/unhide textbutton?
Another question
So I did something like
But this doesn't work well
So I did something like
Code: Select all
init 1:
$ mod_show = False
$ mod_button_show = True
screen admin_screen:
if mod_button_show:
if mod_show == False:
textbutton "Hello" action SetVariable("mod_show", "True")
elif mod_show == True:
textbutton "Hello2" action SetVariable("mod_show", "False")
-
- Regular
- Posts: 159
- Joined: Fri Jan 04, 2019 3:44 pm
- Contact:
Re: Is that possible to hide/unhide textbutton?
True and False in your SetVariable calls should not be quoted. :)
Additionally you could even simplify this to:
Which has the advantage of keeping the variable open contained within the screen itself. If this is not wanted (i.e. you want open to be global) then changing SetScreenVariable to SetVariable should have you covered. :D
Additionally you could even simplify this to:
Code: Select all
screen admin_screen:
default open = False
if open:
textbutton "Hello2" action SetScreenVariable('open', False)
else:
textbutton "Hello" action SetScreenVariable('open', True)
-
- Miko-Class Veteran
- Posts: 793
- Joined: Fri Feb 09, 2018 12:05 am
- Location: Canada
- Contact:
Re: Is that possible to hide/unhide textbutton?
this what I have created
Code: Select all
if mod_button_show:
if mod_show == False:
textbutton "Hello" action SetVariable("mod_show", True) xalign 0.10 ypos 0.02
elif mod_show == True:
textbutton "Hello2" action SetVariable("mod_show", False) xalign 0.10 ypos 0.02
- Imperf3kt
- Lemma-Class Veteran
- Posts: 3792
- Joined: Mon Dec 14, 2015 5:05 am
- itch: Imperf3kt
- Location: Your monitor
- Contact:
Re: Is that possible to hide/unhide textbutton?
I'd simplify it further to
Code: Select all
screen testing():
default var1 = True
vbox:
if var1:
textbutton _("one") action ToggleScreenVariable("var1", False)
else:
textbutton _("two") action ToggleScreenVariable("var1", True)
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
pro·gram·mer (noun) An organism capable of converting caffeine into code.
Current project: GGD Mentor
Re: Is that possible to hide/unhide textbutton?
Thank you again guys it works perfectly!!!
Who is online
Users browsing this forum: No registered users