[solved]Textbutton, selected state criteria ?

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
Ek_Dahl
Newbie
Posts: 4
Joined: Thu Dec 14, 2023 9:55 pm
Contact:

[solved]Textbutton, selected state criteria ?

#1 Post by Ek_Dahl »

Hello, i'm Ekdahl, i have a small trouble with the textbutton selected state where some share the same trigger from the action function... I would like to know if its possible to differentiate them, it seems they use the variable from SetVariable("equipement_selected", key_ring) to define their selected state. I'm not sure how to explain this properly so i'll put a picture, thanks x)

Image

https://iili.io/JulFTUx.png

and the code :

Code: Select all

frame : # Legs Equipement Slot
                            xysize(250, 60)
                            pos(900, 460)
                            background "menus/status_menu/equip_bubble.png"
                            textbutton [Actor_list[index].Equipement_list[3].name] style "custom_button" text_style "small_text" :
                                action SetVariable("slot_selected", 3), SetVariable("equipement_selected", key_legs)

                        frame : # Ring 1 Equipement Slot
                            xysize(250, 60)
                            pos(900, 580)
                            background "menus/status_menu/equip_bubble.png"
                            textbutton [Actor_list[index].Equipement_list[4].name] style "custom_button" text_style "small_text":
                                action SetVariable("slot_selected", 4), SetVariable("equipement_selected", key_ring)
                        frame : # Ring 2 Equipement Slot
                            xysize(250, 60)
                            pos(900, 650)
                            background "menus/status_menu/equip_bubble.png"
                            textbutton [Actor_list[index].Equipement_list[5].name] style "custom_button" text_style "small_text":
                                action SetVariable("slot_selected", 5), SetVariable("equipement_selected", key_ring)

                        frame : # Item 1 Equipement Slot
                            xysize(250, 60)
                            pos(200, 510)
                            background "menus/status_menu/equip_bubble.png"
                            textbutton [Actor_list[index].Equipement_list[6].name] style "custom_button" text_style "small_text" :
                                action SetVariable("slot_selected", 6), SetVariable("equipement_selected", key_item)
                        frame : # Item 2 Equipement Slot
                            xysize(250, 60)
                            pos(200, 580)
                            background "menus/status_menu/equip_bubble.png"
                            textbutton [Actor_list[index].Equipement_list[7].name] style "custom_button" text_style "small_text" :
                                action SetVariable("slot_selected", 7), SetVariable("equipement_selected", key_item)
                        frame : # Item 3 Equipement Slot
                            xysize(250, 60)
                            pos(200, 650)
                            background "menus/status_menu/equip_bubble.png"
                            textbutton [Actor_list[index].Equipement_list[8].name] style "custom_button" text_style "small_text" :
                                action SetVariable("slot_selected", 8), SetVariable("equipement_selected", key_item)
Last edited by Ek_Dahl on Fri Dec 15, 2023 6:42 am, edited 1 time in total.

User avatar
Ocelot
Lemma-Class Veteran
Posts: 2407
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: Textbutton, selected state criteria ?

#2 Post by Ocelot »

If your selected state condition does not match your actions, you can set it explicitely using selected property:

Code: Select all

textbutton "I am a button":
    action NullAction()
    selected 8 == 4 # you can write any condition here.
< < insert Rick Cook quote here > >

Ek_Dahl
Newbie
Posts: 4
Joined: Thu Dec 14, 2023 9:55 pm
Contact:

Re: Textbutton, selected state criteria ?

#3 Post by Ek_Dahl »

Hi, thanks it works perfectly ! :D

Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot]