[Solved] Assigning One-off Alternate Color Highligh to Menu Choice

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
decocloud
Newbie
Posts: 5
Joined: Fri May 13, 2022 7:15 pm
Contact:

[Solved] Assigning One-off Alternate Color Highligh to Menu Choice

#1 Post by decocloud »

Hey there, advance apologies as I have zero idea how to code and I'm kinda struggling with this. My game has some situations where after a set amount of time, a menu choice will "change" into an alternate option. I was able to code the countdown and alternate choice myself, as well as carry over the hover and select sfx via button styles. What I'm struggling with is getting the new choice to highlight with a new hover png so that it is a different color, with this the background changes successfully but I've lost the hover functionality. I thought I might simply be able to add more styling parameters but I'm struggling with the syntax. Any assistance would be greatly appreciated.

Apologies for my extremely hacky code, I have very little idea what I'm doing.

right now I have (in the script)

Code: Select all

label altChoice1:

    label menu1:
        $ time = 0.5
        $ timer_ranger = 0.5
        $ timer_jump = 'menu1_slow'
        show screen countdown

        menu:
            "Option A":
                 jump ahead
            "Option B":
                  jump ahead

label menu1_slow:
    menu:
        "Surprise Option C" (altChoice=True):  
              jump ahead
        "Option B":
              jump ahead
and this (in screens)

Code: Select all

screen choice(items):
    style_prefix "choice"
    
    vbox:
        for i in items:
            $ altChoice = i.kwargs.get("altChoice", False)
            if not altChoice:
                textbutton i.caption action i.action
            if altChoice:
                textbutton i.caption background "images/choice_hover_backgroundALT.png" action i.action
Plus some styling properties

Code: Select all

style choice_textbutton is button
style choice_textbutton_text is button_text

style choice_vbox:
    xalign 0.5
    ypos 405
    yanchor 0.5

    spacing gui.choice_spacing

style choice_textbutton is default:
    properties gui.button_properties("choice_button")
    hover_sound "audio/rollover.ogg"
    activate_sound "audio/choice.ogg"

style choice_button_text is default:
    properties gui.button_text_properties("choice_button")
Last edited by decocloud on Sat May 21, 2022 1:12 am, edited 1 time in total.

philat
Eileen-Class Veteran
Posts: 1909
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: Assigning One-off Alternate Color Highligh to Menu Choice

#2 Post by philat »

Try hover_background instead of background.

decocloud
Newbie
Posts: 5
Joined: Fri May 13, 2022 7:15 pm
Contact:

Re: [Solved] Assigning One-off Alternate Color Highligh to Menu Choice

#3 Post by decocloud »

oh my god that was easy. thank you for the help ;u;

Post Reply

Who is online

Users browsing this forum: Google [Bot]