- The music only works in the Preferences section (where I put the music screen) and as soon as I leave the preferences, the choice disappears (I know it's probably related to the fact that there is already a song played in the background but I can't find where I can replace the song other than config.main_menu_music in options.rpy.
- The name of the song doesn't update when I click on the "<" or ">"
There's two solutions to my problem and although the first one is my number choice of esthetic, I can settle for the second one.
1st:
Code: Select all
init python:
music_playlist = ["audio/PerituneMaterial_Guitar_Melancholy2.mp3","audio/PerituneMaterial_Poema_Guitar.mp3", "audio/PerituneMaterial_Positive.mp3", "audio/PerituneMaterial_Rapid2.mp3"]
music_playlist_name = ["Main theme", "Soft Guitar", "Positive", "Mini-game"]
current_index_playlist = 0
current_index_playlist_name = 0
def next_song():
global current_index_playlist, current_index_playlist_name
current_index_playlist = (current_index_playlist + 1) % len(music_playlist)
current_index_playlist_name = (current_index_playlist_name + 1) % len(music_playlist_name)
config.main_menu_music = [music_playlist[current_index_playlist]]
renpy.music.play(config.main_menu_music)
def previous_song():
global current_index_playlist, current_index_playlist_name
current_index_playlist = (current_index_playlist - 1) % len(music_playlist)
current_index_playlist_name = (current_index_playlist_name - 1) % len(music_playlist_name)
config.main_menu_music = [music_playlist[current_index_playlist]]
renpy.music.play(config.main_menu_music)
screen music_choice():
hbox:
label _("Music")
hbox:
textbutton "<" action previous_song
text "[music_playlist_name[current_index_playlist_name]]" id "song_name"
textbutton ">" action next_song
2nd:
Code: Select all
init python:
music_choice = [("Main theme", "audio/PerituneMaterial_Guitar_Melancholy2.mp3"), ("Soft Guitar", "audio/PerituneMaterial_Poema_Guitar.mp3"), ("Positive", "audio/PerituneMaterial_Positive.mp3"), ("Mini-game", "audio/PerituneMaterial_Rapid2.mp3")]
screen music_choice():
hbox:
label _("Music")
vbox:
for choice in music_choice:
textbutton choice[0] action [SetVariable("chosen_music", choice[1]), Play(chosen_music)]
Code: Select all
```
I'm sorry, but an uncaught exception occurred.
While running game code:
File "game/screens.rpy", line 828, in execute
screen preferences():
File "game/screens.rpy", line 828, in execute
screen preferences():
File "game/screens.rpy", line 832, in execute
use game_menu(_("Preferences"), scroll="viewport"):
File "game/screens.rpy", line 424, in execute
screen game_menu(title, scroll=None, yinitial=0.0):
File "game/screens.rpy", line 424, in execute
screen game_menu(title, scroll=None, yinitial=0.0):
File "game/screens.rpy", line 433, in execute
frame:
File "game/screens.rpy", line 436, in execute
hbox:
File "game/screens.rpy", line 442, in execute
frame:
File "game/screens.rpy", line 445, in execute
if scroll == "viewport":
File "game/screens.rpy", line 447, in execute
viewport:
File "game/screens.rpy", line 456, in execute
vbox:
File "game/screens.rpy", line 457, in execute
transclude
File "game/screens.rpy", line 832, in execute
use game_menu(_("Preferences"), scroll="viewport"):
File "game/screens.rpy", line 834, in execute
vbox:
File "game/screens.rpy", line 866, in execute
hbox:
File "game/screens.rpy", line 870, in execute
vbox:
File "game/screens.rpy", line 881, in execute
use music_choice()
File "game/mes_screens.rpy", line 653, in execute
screen music_choice():
File "game/mes_screens.rpy", line 653, in execute
screen music_choice():
File "game/mes_screens.rpy", line 654, in execute
hbox:
File "game/mes_screens.rpy", line 656, in execute
vbox:
File "game/mes_screens.rpy", line 657, in execute
for choice in music_choice:
File "game/mes_screens.rpy", line 658, in execute
textbutton choice[0] action [SetVariable("chosen_music", choice[1]), Play(chosen_music)]
File "game/mes_screens.rpy", line 658, in keywords
textbutton choice[0] action [SetVariable("chosen_music", choice[1]), Play(chosen_music)]
File "game/mes_screens.rpy", line 658, in <module>
textbutton choice[0] action [SetVariable("chosen_music", choice[1]), Play(chosen_music)]
NameError: name 'chosen_music' is not defined
Code: Select all
```
I'm sorry, but an uncaught exception occurred.
While running game code:
File "game/screens.rpy", line 828, in execute
screen preferences():
File "game/screens.rpy", line 828, in execute
screen preferences():
File "game/screens.rpy", line 832, in execute
use game_menu(_("Preferences"), scroll="viewport"):
File "game/screens.rpy", line 424, in execute
screen game_menu(title, scroll=None, yinitial=0.0):
File "game/screens.rpy", line 424, in execute
screen game_menu(title, scroll=None, yinitial=0.0):
File "game/screens.rpy", line 433, in execute
frame:
File "game/screens.rpy", line 436, in execute
hbox:
File "game/screens.rpy", line 442, in execute
frame:
File "game/screens.rpy", line 445, in execute
if scroll == "viewport":
File "game/screens.rpy", line 447, in execute
viewport:
File "game/screens.rpy", line 456, in execute
vbox:
File "game/screens.rpy", line 457, in execute
transclude
File "game/screens.rpy", line 832, in execute
use game_menu(_("Preferences"), scroll="viewport"):
File "game/screens.rpy", line 834, in execute
vbox:
File "game/screens.rpy", line 866, in execute
hbox:
File "game/screens.rpy", line 870, in execute
vbox:
File "game/screens.rpy", line 881, in execute
use music_choice()
File "game/mes_screens.rpy", line 653, in execute
screen music_choice():
File "game/mes_screens.rpy", line 653, in execute
screen music_choice():
File "game/mes_screens.rpy", line 654, in execute
hbox:
File "game/mes_screens.rpy", line 656, in execute
vbox:
File "game/mes_screens.rpy", line 657, in execute
for choice in music_choice:
File "game/mes_screens.rpy", line 658, in execute
textbutton choice[0] action [SetVariable("chosen_music", choice[1]), Play("chosen_music")]
File "game/mes_screens.rpy", line 658, in keywords
textbutton choice[0] action [SetVariable("chosen_music", choice[1]), Play("chosen_music")]
File "game/mes_screens.rpy", line 658, in <module>
textbutton choice[0] action [SetVariable("chosen_music", choice[1]), Play("chosen_music")]
TypeError: __init__() missing 1 required positional argument: 'file'