Adding a main menu music option to options screen

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
joehair
Newbie
Posts: 2
Joined: Sun Mar 13, 2022 11:31 pm
itch: studiojoe
Contact:

Adding a main menu music option to options screen

#1 Post by joehair »

Hi,

I'm trying to figure out (to no avail) how can I add an option to the options menu, specifically an option to choose which track a player would like to use for the main menu theme. I do not know how to add an option in general so I'm kinda puzzled right now.

Any help is appreciated.

Sincerely,
Joe
Quandale Dingle Supremacy 8) 8) 8)

User avatar
Per K Grok
Miko-Class Veteran
Posts: 882
Joined: Fri May 18, 2018 1:02 am
Completed: the Ghost Pilot, Sea of Lost Ships, Bubbles and the Pterodactyls, Defenders of Adacan Part 1-3, the Phantom Flyer
itch: per-k-grok
Location: Sverige
Contact:

Re: Adding a main menu music option to options screen

#2 Post by Per K Grok »

joehair wrote: Sun Mar 13, 2022 11:36 pm Hi,

I'm trying to figure out (to no avail) how can I add an option to the options menu, specifically an option to choose which track a player would like to use for the main menu theme. I do not know how to add an option in general so I'm kinda puzzled right now.

Any help is appreciated.

Sincerely,
Joe

I take it that you are talking about preferences.

So you go to the screen.rpy file

Find
'screen preferences():'

go down to
## Additional vboxes of type "radio_pref" or "check_pref" can be
## added here, to add additional creator-defined preferences.

and you can add something like this

Code: Select all

                vbox:
                    style_prefix "radio"
                    label _("Main Menu Music")
                    textbutton _("Track 1") action NullAction()
                    textbutton _("Track 2") action NullAction()
                    textbutton _("Track 3") action NullAction()
                    textbutton _("Track 4") action NullAction()    
                         
This code will give you the buttons, but with *NullAction()' they don't do anything.

Changing the main menu music will have some complications depending on what you want to do.
Typically the player don't spend much time at the main menu, so this might not be a good thing to put too much work into.

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

Re: Adding a main menu music option to options screen

#3 Post by Imperf3kt »

I just do it this way:

Code: Select all

default m_music = None

screen main_menu():
    tag menu
    on "show" action Play("music", m_music)
Then you just set the value of the variable "m_music" in the usual ways (as an action or by setting it with python) to the name of the audio you want to use.
You may need to use a persistent variable if you want to set/change the music permanently (until it is changed again, at least)
Last edited by Imperf3kt on Tue Mar 15, 2022 3:32 am, edited 2 times in total.
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor

Twitter

joehair
Newbie
Posts: 2
Joined: Sun Mar 13, 2022 11:31 pm
itch: studiojoe
Contact:

Re: Adding a main menu music option to options screen

#4 Post by joehair »

thanks guys! I'll report results after testing.
Quandale Dingle Supremacy 8) 8) 8)

Post Reply

Who is online

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