Setting a button as not selected.[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
TellerFarsight
Veteran
Posts: 230
Joined: Sun Jun 04, 2017 8:09 pm
Projects: Vora, Secrets Untold
Location: Toronto, ON
Contact:

Setting a button as not selected.[SOLVED]

#1 Post by TellerFarsight »

I have a screen (called), on which one of the buttons displays another screen (with show). The text overlays the buttons to indicate what they do. The third button (the unit.name) button calls the secondary menu. Once the second menu is called, I can't get it to go away. The "Back" button is supposed to hide the screen, but it doesn't. I know it's working because I stuck the 'fade' transition on it, so when the I click it the screen goes to black and comes back with nothing changing. I have a feeling the screen is still displayed because the unit.name button is still selected, but how do I fix that?

Code: Select all

screen your_turn(unit):
    modal True
    vbox:
        xpos 20
        ypos 60
        imagebutton auto "gui/Battle/phase_button_%s.png" action SensitiveIf(unit.move_flag)
        imagebutton auto "gui/Battle/phase_button_%s.png" action SensitiveIf(unit.attack_flag)
        imagebutton auto "gui/Battle/phase_button_%s.png" action Show("your_turn2", None, unit)
        imagebutton auto "gui/Battle/phase_button_%s.png" action Return()
    vbox:
        xpos 25
        ypos 65
        spacing 4
        text "Move"
        text "Attack"
        text unit.name
        text "End"

screen your_turn2(unit):
    modal True
    vbox:
        xpos 270
        ypos 140
        imagebutton auto "gui/Battle/phase_button_%s.png" action NullAction()
        imagebutton auto "gui/Battle/phase_button_%s.png" action Hide("Your_turn2",fade)
    vbox:
        xpos 275
        ypos 145
        spacing 4
        text "Summon"
        text "Back"
Here's what it looks like:
battlemenuexample.png
I tried to fix it by using SelectedIf, but for some reason this didn't work, returning the error "attribute name must be strong, not 'bool'"

Code: Select all

screen your_turn(unit):
    modal True
    vbox:
        xpos 20
        ypos 60
        imagebutton auto "gui/Battle/phase_button_%s.png" action SensitiveIf(unit.move_flag)
        imagebutton auto "gui/Battle/phase_button_%s.png" action SensitiveIf(unit.attack_flag)
        imagebutton auto "gui/Battle/phase_button_%s.png" action [SetVariable(unit.name_flag, True), SelectedIf(unit.name_flag), Show("your_turn2", None, unit)]
        imagebutton auto "gui/Battle/phase_button_%s.png" action Return()
    vbox:
        xpos 25
        ypos 65
        spacing 4
        text "Move"
        text "Attack"
        text unit.name
        text "End"

screen your_turn2(unit):
    modal True
    vbox:
        xpos 270
        ypos 140
        imagebutton auto "gui/Battle/phase_button_%s.png" action NullAction()
        imagebutton auto "gui/Battle/phase_button_%s.png" action [SetVariable(unit.name_flag, False), Hide("Your_turn2",fade)]
    vbox:
        xpos 275
        ypos 145
        spacing 4
        text "Summon"
        text "Back"
Last edited by TellerFarsight on Tue Sep 12, 2017 10:14 pm, edited 1 time in total.
Current Project: Vora
Also Check Out: Devil Survivor [Reverse-Engineered]

User avatar
Kia
Eileen-Class Veteran
Posts: 1040
Joined: Fri Aug 01, 2014 7:49 am
Deviantart: KiaAzad
Discord: Kia#6810
Contact:

Re: Setting a button as not selected.

#2 Post by Kia »

from what I see it should work correctly, is it possible that your code shows the same menu twice?
for solution I have two to offer:
1st- tag your screens to replace each other and try hiding them by their tags, this way you can be sure that only one of the screens with the same tag is showing in any given time:

Code: Select all

screen your_turn(unit):
	tag menu_1
	...

screen your_turn2(unit):
	tag menu_2
	...
2nd- use "if" and use to show/hide sub menus

Code: Select all

if your_turn_2:
	use your_turn2
:

User avatar
TellerFarsight
Veteran
Posts: 230
Joined: Sun Jun 04, 2017 8:09 pm
Projects: Vora, Secrets Untold
Location: Toronto, ON
Contact:

Re: Setting a button as not selected.

#3 Post by TellerFarsight »

...
I figured it out...
I can even see it in this code here.

Show(your_turn2...
Hide(Your_turn2...

Oops.
Current Project: Vora
Also Check Out: Devil Survivor [Reverse-Engineered]

Post Reply

Who is online

Users browsing this forum: No registered users