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.
-
vorgbardo
- Regular
- Posts: 27
- Joined: Sun Jan 14, 2018 8:28 am
- Projects: Head Case
-
Contact:
#1
Post
by vorgbardo » Sat Sep 10, 2022 3:40 pm
I'm using the default Main and Game Menu Screens. I've added hover_sound and activate_sound to the textbuttons. That works otherwise nicely, but the hover_sound activates also in cases where the hover colour does not. For example, if the user is on Preferences page and hovers over the menu textbuttons, hover colour does not activate for the Preferences textbutton, but the hover_sound does. I tried to find out where the code for the smart hover colour is, but failed. 1) Anyone able to point out how the default Menu Screen knows not to use the hover colour for the textbutton of the current screen? 2) What is the smartest way to add similar logic to the hover_sound?
Example code of current Preferences textbutton:
Code: Select all
textbutton _("PREFERENCES"):
hover_sound "audio/hover1e.mp3"
activate_sound "audio/blip1.mp3"
action ShowMenu("preferences")
A dyslexic man walks into a bra.
-
Andredron
- Miko-Class Veteran
- Posts: 535
- Joined: Thu Dec 28, 2017 2:37 pm
- Completed: Kimi ga nozomu renpy-port(demo), Albatross Koukairoku(demo)
- Projects: Sisters ~Natsu no Saigo no Hi~(renpy-port)
- Location: Russia
-
Contact:
#2
Post
by Andredron » Sun Sep 11, 2022 8:07 am
Write a condition for the button
Code: Select all
textbutton "Unseen text":
action Preference("skip", "toggle")
if pppp == "True":
activate_sound "audio/effects/sound_01.ogg"
else:
pass
We register the screen in which the variable will change, and we will register the back button, change the value of the variable
Code: Select all
screen ereasr:
$ pppp = True
.............
textbutton _("return"):
action [SetField("pppp" , False),Return()]
# Or:
textbutton _("return"):
action [SetVariable("pppp" , False),Return()]
-
vorgbardo
- Regular
- Posts: 27
- Joined: Sun Jan 14, 2018 8:28 am
- Projects: Head Case
-
Contact:
#3
Post
by vorgbardo » Mon Sep 12, 2022 9:23 pm
Thank you for the answer! I'm not quite sure how to use it to solve my question, I probably just don't understand it.

Nonetheless, I currently solved the problem like this:
Code: Select all
textbutton _([preferencestext]):
activate_sound "audio/blip1.mp3"
action ShowMenu("preferences")
if not renpy.get_screen("preferences"):
hover_sound "audio/hover1e.mp3"
I'm still wondering if there'd be some way to automate this more without the need to write that code for every similar navigation button in the game, because there is clearly some kind of automation already in place for the hover colour in similar situations. If there is a way let me know, but this now works.
Another thing I'd like to add to this is underlining the navigation textbutton text for the textbutton of the current location, to make it more clear that the user is now on that particular page. I tried the following, but it does not work. What would be the correct way to create the underlining (non-working line is the last one)?
Code: Select all
textbutton _([preferencestext]):
activate_sound "audio/blip1.mp3"
action ShowMenu("preferences")
if not renpy.get_screen("preferences"):
hover_sound "audio/hover1e.mp3"
else
underline True
A dyslexic man walks into a bra.
-
enaielei
- Regular
- Posts: 114
- Joined: Fri Sep 17, 2021 2:09 am
- Tumblr: enaielei
- Deviantart: enaielei
- Github: enaielei
- Skype: enaielei
- Soundcloud: enaielei
- itch: enaielei
- Discord: enaielei#7487
-
Contact:
#4
Post
by enaielei » Tue Sep 13, 2022 12:13 am
I'm still wondering if there'd be some way to automate this more without the need to write that code for every similar navigation button in the game, because there is clearly some kind of automation already in place for the hover colour in similar situations.
You can also use screens.
Code: Select all
screen nav_btn(text, screen):
textbutton _([text]):
activate_sound "audio/blip1.mp3"
action ShowMenu(screen)
if not renpy.get_screen(screen):
hover_sound "audio/hover1e.mp3"
screen test():
vbox:
use nav_btn("Prefs", "preferences")
use nav_btn("Load", "load")
What would be the correct way to create the underlining (non-working line is the last one)?
Prefix your styles with text_.
underline ->
text_underline.
-
vorgbardo
- Regular
- Posts: 27
- Joined: Sun Jan 14, 2018 8:28 am
- Projects: Head Case
-
Contact:
#5
Post
by vorgbardo » Mon Sep 19, 2022 11:08 am
enaielei wrote: ↑Tue Sep 13, 2022 12:13 am
Prefix your styles with text_.
underline ->
text_underline.
Thank you, this worked perfectly! And thank you also for the screens tip.
A dyslexic man walks into a bra.
Users browsing this forum: Bing [Bot], Google [Bot], Majestic-12 [Bot]