selected state button by value variable

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
smollvrn
Newbie
Posts: 14
Joined: Sun Mar 14, 2021 3:24 pm
Contact:

selected state button by value variable

#1 Post by smollvrn » Tue Aug 24, 2021 1:37 pm

Hi, would some help me understand why button get selected state without a click. if i try set by button one of variable to value what its already have, button get selected state. i can not find read about it

Code: Select all

init:
 $ vari= False
 $ vari2= True
style button:
    background "#006"
    insensitive_background "#444"
    hover_background "#00a" 
    selected_background "#fff"
style button_text:
  color "#fff"
  hover_color "#0f0"
  selected_color "#F00"
screen button:
 vbox:
  text"by default vari=False vari2=True"
  textbutton "Vari=False":
   action SetVariable("vari", False)
   style "button"
  textbutton "vari=True":
   action SetVariable("vari", True)
   style "button"
  textbutton "vari2=True":
   action SetVariable("vari2", True)
   style "button"
  textbutton "vari2=False":
   action SetVariable("vari2", False)
   style "button"
  textbutton "Exit":
   action Return()
  text "Current status:vari=[vari],vari2=[vari2]" 
screen button2:
 vbox:
  text"by default vari=False vari2=True"
  textbutton "vari=False,vari2=False":
   action [SetVariable("vari", False), SetVariable("vari2", False)]
   style "button"
  textbutton "vari=True,vari2=True":
   action [SetVariable("vari", True), SetVariable("vari2", True)]
   style "button"
  textbutton "vari=True,vari2=True":
   action [SetVariable("vari", True), SetVariable("vari2", True)]
   style "button"
  textbutton "vari=True,vari2=false":
   action [SetVariable("vari", True), SetVariable("vari2", False)]
   style "button"
  textbutton "exit":
   action Return()   
  text "Current status:vari=[vari],vari2=[vari2]"  

   
label start:
 scene black
 call screen button
 call screen button2

rayminator
Miko-Class Veteran
Posts: 754
Joined: Fri Feb 09, 2018 12:05 am
Location: Canada
Contact:

Re: selected state button by value variable

#2 Post by rayminator » Tue Aug 24, 2021 1:59 pm

you just need to use style "button" once not per textbutton put it in between vbox and the first textbutton and I would space out the textbutton & text using yspacing 5

something like this

Code: Select all

screen button2:
    vbox:
        style "button"
        
        text"by default vari=False vari2=True"
        textbutton "vari=False,vari2=False":
            action [SetVariable("vari", False), SetVariable("vari2", False)]

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

Re: selected state button by value variable

#3 Post by Alex » Tue Aug 24, 2021 2:03 pm

smollvrn wrote:
Tue Aug 24, 2021 1:37 pm
... i can not find read about it...
Here's some - viewtopic.php?f=51&t=60864

smollvrn
Newbie
Posts: 14
Joined: Sun Mar 14, 2021 3:24 pm
Contact:

Re: selected state button by value variable

#4 Post by smollvrn » Tue Aug 24, 2021 2:16 pm

Alex wrote:
Tue Aug 24, 2021 2:03 pm
smollvrn wrote:
Tue Aug 24, 2021 1:37 pm
... i can not find read about it...
Here's some - viewtopic.php?f=51&t=60864
thanks

Post Reply

Who is online

Users browsing this forum: Google [Bot]