[SOLVED] Music on a 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
User avatar
Shocking Alberto
Regular
Posts: 31
Joined: Sun Mar 29, 2020 4:58 am
Contact:

[SOLVED] Music on a Screen?

#1 Post by Shocking Alberto » Mon Jul 06, 2020 10:39 pm

Curious to know if there's a way to play music on a screen besides using the MusicRoom screen code? I'm building a CG/event gallery right now and while music is playing in said gallery, which is piped in from the BGM set for the main menu, it would be ideal to be able to use a different track for the gallery itself. Short of making a button to use an action to use a music file, I'm not sure what other options there are.

If a thread on this already exists, just kick me to the thread. I'll figure it out from there. o/
Last edited by Shocking Alberto on Sun Jul 12, 2020 4:25 pm, edited 1 time in total.

User avatar
Shocking Alberto
Regular
Posts: 31
Joined: Sun Mar 29, 2020 4:58 am
Contact:

Re: Music on a Screen?

#2 Post by Shocking Alberto » Mon Jul 06, 2020 11:00 pm

After some searching, it seems the easiest is still to change the action from screens.rpg to go to a label where you can change the music then call the screen for the CG gallery.

Only problem is if you exit the gallery, it will be playing the music from the gallery, rather than the main menu. Welp, nearly there... /o/

User avatar
Jackkel Dragon
Veteran
Posts: 239
Joined: Mon Mar 31, 2014 7:17 pm
Organization: Nightshade, Team Despair
itch: jackkel-dragon
Location: USA
Contact:

Re: Music on a Screen?

#3 Post by Jackkel Dragon » Tue Jul 07, 2020 1:36 pm

The simple idea that comes to mind is to use multiple actions. On the button to enter the gallery, instead of

Code: Select all

action <action>
use:

Code: Select all

action [<action>, <action>]
This will play the actions from the list, in order. As long as you play music before you switch screens, it should carry over.

For returning to the title screen, you could use the dedicated main menu action instead of "return", or do the above method to change the music before popping the current screen to return.

There's a complex idea that comes to mind that involves overriding internal labels, but I don't know if it would even work. I'd heavily recommend the multiple action list for the related buttons.
Main Website
Includes information about and links to many of my current and past projects.

Major Game Projects
[Nightshade] Eldritch Academy, Eldritch University, Blooming Nightshade, Flowering Nightshade, Life as Designed
[Team Despair] Corpse Party D2 series

User avatar
Shocking Alberto
Regular
Posts: 31
Joined: Sun Mar 29, 2020 4:58 am
Contact:

Re: Music on a Screen?

#4 Post by Shocking Alberto » Sun Jul 12, 2020 3:48 pm

Thank you for the suggestion! I keep forgetting that you can use multiple actions at once.

With that said, it seems that the button to return back to the main menu with no longer becomes responsive when you add multiple actions. Currently I am using this code which should work:

Code: Select all

    imagebutton:
        xalign 0.98
        yalign 0.98
        idle "gui/return.png"
        hover "gui/return_hover.png"
        hovered Play ("sound", "SE/sound_hover.ogg")
        activate_sound "SE/sound_click.ogg"
        action [Call("music_reset"), MainMenu(confirm=False)]
The "music_reset" label itself just contains a single line to play the main menu screen and that's it. Maybe there's some limitations as to what can be put in the action line. Guess I'll snoop around some more till I figure it out.

User avatar
Shocking Alberto
Regular
Posts: 31
Joined: Sun Mar 29, 2020 4:58 am
Contact:

Re: Music on a Screen?

#5 Post by Shocking Alberto » Sun Jul 12, 2020 4:25 pm

Okay, never mind I am dumb and didn't read the documentation thoroughly. Again. I forgot that there were audio actions I can use and it worked as suggested. Thanks, Jackkel!

Post Reply

Who is online

Users browsing this forum: Ende