[SOLVED] Make a "Jump" Button appear "On" or "Off"

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
Kinmoku
Miko-Class Veteran
Posts: 560
Joined: Mon Aug 11, 2014 9:39 am
Completed: One Night Stand
Projects: Love IRL, Memories
Tumblr: gamesbykinmoku
itch: kinmoku
Location: Germany
Contact:

[SOLVED] Make a "Jump" Button appear "On" or "Off"

#1 Post by Kinmoku » Thu May 02, 2019 10:26 am

Hi all.

I'm trying to figure out how to make a Jump button appear in an "on" or "off" state, like a Preference("on", "off") button would.

My button is for fast-forwarding/ skipping text, which can be selected in the pause menu. I've done it this way as a direct Skip would immediately go off the pause menu, which I didn't want. Thread here: viewtopic.php?f=8&t=54973

The button jumps to the label "skip_toggle" in script.rpy:

Code: Select all

            button:
                action Jump("skip_toggle")
                style "mainmenu_choice_button"
                text _("Fast-Forward") style "mainmenu_choice"

# script.rpy

label skip_toggle:
    if fastforward == "off":
        $ fastforward = "on"
        
    else:
        $ fastforward = "off"
        
    call screen pause_screen
But the button doesn't have an "on" or "selected" state, so it doesn't let the player know it's actually on or not.

I tried adding a few things but nothing worked properly. How do I do this?
Last edited by Kinmoku on Mon May 06, 2019 4:41 am, edited 1 time in total.

User avatar
Saa
Regular
Posts: 32
Joined: Tue Aug 20, 2013 7:11 pm
Tumblr: nipahgirl
Contact:

Re: Make a "Jump" Button appear "On" or "Off"

#2 Post by Saa » Sat May 04, 2019 6:37 pm

Doesn't making the button ToggleVariable work? I'm guessing fastforward is a global variable, and you should make it a boolean if its only values are on and off.

Code: Select all

button:
    action [ToggleVariable("fastforward"), Call("pause_screen")]
    style "mainmenu_choice_button"
    text _("Fast-Forward") style "mainmenu_choice"
You won't need skip_toggle anymore.

User avatar
Matalla
Veteran
Posts: 202
Joined: Wed Mar 06, 2019 6:22 pm
Completed: The Lost Smile
itch: matalla-interactive
Location: Spain
Contact:

Re: Make a "Jump" Button appear "On" or "Off"

#3 Post by Matalla » Sat May 04, 2019 7:34 pm

I don't know exactly what you're trying to do, but if I understand correctly, you want the button to reflect the state of the variable "fastforward"; if its "on", button should appear selected, right?

I think that adding this to the button definition should do that (if the style "mainmenu_choice" has a selected state)

Code: Select all

selected fastforward == "on"
Comunidad Ren'Py en español (Discord)
Honest Critique

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3636
Joined: Mon Dec 14, 2015 5:05 am
Location: Your monitor
Contact:

Re: Make a "Jump" Button appear "On" or "Off"

#4 Post by Imperf3kt » Sat May 04, 2019 8:42 pm

You can always use these within the image block to determine what to show on those states.
selected
selected_idle
selected_hover
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor
Free Android GUI - Updated occasionally
Twitter
Imperf3kt Blackjack - a WIP blackjack game for Android made using Ren'Py

User avatar
Kinmoku
Miko-Class Veteran
Posts: 560
Joined: Mon Aug 11, 2014 9:39 am
Completed: One Night Stand
Projects: Love IRL, Memories
Tumblr: gamesbykinmoku
itch: kinmoku
Location: Germany
Contact:

Re: Make a "Jump" Button appear "On" or "Off"

#5 Post by Kinmoku » Mon May 06, 2019 4:13 am

Hi everyone, thanks for the help. Sadly, nothing is working :(
Saa wrote:
Sat May 04, 2019 6:37 pm
Doesn't making the button ToggleVariable work? I'm guessing fastforward is a global variable, and you should make it a boolean if its only values are on and off.
CODE: SELECT ALL

button:
action [ToggleVariable("fastforward"), Call("pause_screen")]
style "mainmenu_choice_button"
text _("Fast-Forward") style "mainmenu_choice"
- I originally tried this as I was sure it'd work, but the button looks "on" by default but isn't. When I click, it does nothing. I tried it with True or False and it still didn't work.
Matalla wrote:
Sat May 04, 2019 7:34 pm
I think that adding this to the button definition should do that (if the style "mainmenu_choice" has a selected state)
CODE: SELECT ALL

selected fastforward == "on"
- I really thought this would work, but the button looks "off" and nothing happens when I click.
Imperf3kt wrote:
Sat May 04, 2019 8:42 pm
You can always use these within the image block to determine what to show on those states.
selected
selected_idle
selected_hover
I tried this originally but it didn't work. The closest I got was: "if fastforward == "on", show button in on state" but it would only do this when you reload the pause menu, hence it didn't look like the click registered to the player.

Here's the menu style I'm using - pretty normal stuff:

Code: Select all

    style.mainmenu_choice_button.background = "images/mm_button1.png"
    style.mainmenu_choice_button.hover_background = "mm_button_jiggle"
    style.mainmenu_choice_button.selected_background = "images/mm_button_on.png"
    
This must be possible >_<

User avatar
Kinmoku
Miko-Class Veteran
Posts: 560
Joined: Mon Aug 11, 2014 9:39 am
Completed: One Night Stand
Projects: Love IRL, Memories
Tumblr: gamesbykinmoku
itch: kinmoku
Location: Germany
Contact:

Re: Make a "Jump" Button appear "On" or "Off"

#6 Post by Kinmoku » Mon May 06, 2019 4:41 am

Saa wrote:
Sat May 04, 2019 6:37 pm
Doesn't making the button ToggleVariable work? I'm guessing fastforward is a global variable, and you should make it a boolean if its only values are on and off.
CODE: SELECT ALL

button:
action [ToggleVariable("fastforward"), Call("pause_screen")]
style "mainmenu_choice_button"
text _("Fast-Forward") style "mainmenu_choice"
You won't need skip_toggle anymore.
Never-mind, you were right, Saa! :D I just needed to add to the toggle variable:

Code: Select all

            button:
                action ToggleVariable("fastforward", "on", "off") 
                style "mainmenu_choice_button"
                text _("Fast-Forward") style "mainmenu_choice"
This works as desired, now :) Thanks for helping everyone!

Post Reply

Who is online

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