Why both buttons are highlighted? [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
Luxliev
Veteran
Posts: 242
Joined: Sat Feb 07, 2015 11:01 am
Soundcloud: Luxliev
Contact:

Why both buttons are highlighted? [SOLVED]

#1 Post by Luxliev »

Whenever I choose one of the options (Skill or Magic) both buttons are highlighted. Why this keeps happening and how I can fix this?

Video showing what's going on:
https://www.youtube.com/watch?v=T9pMINEyCx4

Code:

Code: Select all

init python:
    x = 0
    y = 0
    # choice
    ch = 0

screen battle_menu_1():
    # Screen used for selecting skills
    default ch = 0
    vbox:
        style_group "skill"
        align (0.01,0.02)
        textbutton "[attack.name]":
            action [SetVariable('ch', 0), Return (value=attack)]
        if player.skills:
            textbutton "Skills":
                action [SetVariable('ch', 1), Show('battle_menu_2')]
        if player.magic:
            textbutton "Magic":
                action [SetVariable('ch', 2), Show('battle_menu_2')]
        textbutton "[escape.name]" action Return (value=escape)

style skill_button_text:
    size 40
    xminimum 200

            
screen battle_menu_2():
    if ch == 1:
        vbox style_group "bm2" align (.25,0.02):
            for skill in player.skills:
                textbutton "[skill.name]":
                    action [SetVariable('ch', 0), Hide('battle_menu_tooltip'), Return (value=skill)]
                    hovered Show('battle_menu_tooltip')
                    unhovered Hide('battle_menu_tooltip')

    if ch == 2:
        vbox style_group "bm2" align (.25,0.02):
            for magic in player.magic:
                textbutton "[magic.name]":
                    action [SetVariable('ch', 0), Hide('battle_menu_tooltip'), Return (value=magic)]
                    hovered Show('battle_menu_tooltip')
                    unhovered Hide('battle_menu_tooltip')

style bm2_button_text:
    size 40
    xminimum 200

screen battle_menu_tooltip():
    vbox:
        # pos (x+372, y)
        align (.4,0.02)
        textbutton "Tooltip"
Last edited by Luxliev on Tue Jun 20, 2017 8:45 am, edited 1 time in total.
Newest classical cover: Advance Wars - Sami Theme: https://www.youtube.com/watch?v=657Jt7hJRVc

Forum with my music: http://luxliev.proboards.com/

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

Re: Why both buttons are highlighted?

#2 Post by Alex »

I think it happenes 'cause both buttons do show 'battle_menu_2' screen, so when it's onscreen buttons became selected.
Check this (very usefull) post - viewtopic.php?f=8&t=26492&hilit=selected#p322596

User avatar
Luxliev
Veteran
Posts: 242
Joined: Sat Feb 07, 2015 11:01 am
Soundcloud: Luxliev
Contact:

Re: Why both buttons are highlighted?

#3 Post by Luxliev »

Thanks for link. You were correct. After creating 2 screens. One for each option, buttons highlight correctly.
Newest classical cover: Advance Wars - Sami Theme: https://www.youtube.com/watch?v=657Jt7hJRVc

Forum with my music: http://luxliev.proboards.com/

Post Reply

Who is online

Users browsing this forum: Google [Bot]