[SOLVED] Defining what song title shows up in the music room?

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
bluebat
Newbie
Posts: 20
Joined: Tue Nov 13, 2018 10:12 pm
Contact:

[SOLVED] Defining what song title shows up in the music room?

#1 Post by bluebat »

Hey Lemmasoft, I've run into a snag with trying to make a music room for my project.

I've gotten as far as making it so the music room displays the song's filename on the screen while it's playing using this:

Code: Select all

$ playing = renpy.music.get_playing("music")
    if playing is not None:
        text playing xpos 0.5 ypos 0.5
    else:
        text "Press play!" xpos 0.5 ypos 0.5
But of course that understandably comes out looking like "soundfolder/gamemusicfolder/songtitle.ogg". I'd like it so I could define what each file being played displayed as, so it would show up as something like "Song Title - Artist" instead of the file's path. After much googling and experimenting I've had no luck, so any help would be greatly appreciated. Thank you!
Last edited by bluebat on Tue Apr 06, 2021 10:15 am, edited 1 time in total.
So much code, so little time...

User avatar
Ocelot
Lemma-Class Veteran
Posts: 2428
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: Defining what song title shows up in the music room?

#2 Post by Ocelot »

One possible approach would be to create a dictionary mapping files to song names:

Code: Select all

# Somewhere where you define variables
define song_list = {
    "soundfolder/gamemusicfolder/songtitle.ogg" : "Song Title - Artist",
    "soundfolder/gamemusicfolder/anothersong.ogg" : "Another Song - IDK Who",
}

# Then in your screen:
text song_list.get(playing, playing) xpos 0.5 ypos 0.5
This will show name of the sont if it exist in the song_list dictionary, or raw path if it does not.
< < insert Rick Cook quote here > >

User avatar
bluebat
Newbie
Posts: 20
Joined: Tue Nov 13, 2018 10:12 pm
Contact:

Re: Defining what song title shows up in the music room?

#3 Post by bluebat »

Ocelot wrote: Thu Mar 25, 2021 5:35 am One possible approach would be to create a dictionary mapping files to song names:

Code: Select all

# Somewhere where you define variables
define song_list = {
    "soundfolder/gamemusicfolder/songtitle.ogg" : "Song Title - Artist",
    "soundfolder/gamemusicfolder/anothersong.ogg" : "Another Song - IDK Who",
}

# Then in your screen:
text song_list.get(playing, playing) xpos 0.5 ypos 0.5
This will show name of the sont if it exist in the song_list dictionary, or raw path if it does not.
This worked perfectly, thank you so much for your help! :mrgreen:
So much code, so little time...

Post Reply

Who is online

Users browsing this forum: Google [Bot]