As for this code from the online documentation does this work for the music channel or other channels as well
Code: Select all
define audio.sunflower = "music/sun-flower-slow-jam.ogg"
Code: Select all
define audio.sunflower = "music/sun-flower-slow-jam.ogg"
This code will shuffle order of songs and play them.lsf22 wrote: ↑Thu Mar 03, 2022 11:22 pm Im trying to add music to my script that has a Day/Night cycle to a main hub that has music playing in the background but not in order but a shuffle/Random play function. I've tried testing out the code from the music room as an example but that doesn't even work as a code set to test and learn from. I'm new to Renpy so what solutions and alternatives would I have?
Code: Select all
define audio.snap = "audio/ch1_FingerSnap.wav"
define audio.broken_clock = "audio/Clock_Stop.wav"
define audio.angela = "audio/ch8_kether_ep1_malkuth1.wav"
define audio.shot = "audio/Assassination.wav"
define audio.awakening = "audio/BossBird_Birth.wav"
label start_music:
python:
playlist = [audio.snap, audio.broken_clock, audio.angela, audio.shot, audio.awakening]
renpy.random.shuffle(playlist)
play music playlist
return
label start:
call start_music
"You can hear music, playing in randomised order, looping"
call start_music
"Music order was re-shuffled"
return
It defines a name in audio namespace. Channels have no relation to that, they only matter when playing something.lsf22 wrote: ↑Thu Mar 03, 2022 11:22 pm As for this code from the online documentation does this for the music channel or other channels as wellCode: Select all
define audio.sunflower = "music/sun-flower-slow-jam.ogg"
Code: Select all
abel start:
call start_music
"You can hear music, playing in randomised order, looping"
call start_music
"Music order was re-shuffled"
return
Code: Select all
#A room hub script with a Day and Night time cycle
#Stats for the character to gain from activities
default strength = 0
default intelligence = 0
default charm = 0
default money = 0
label Daytime:
scene bg_blue
menu:
"It's currently daytime, what do you want to do?"
"Workout":
"You worked out during the day"
$ strength +=1
jump Nighttime
"Work":
"You went to work"
$ money +=10
jump Nighttime
label Nighttime:
scene bg_blue
menu:
"It's currently nighttime, What do you want to do?"
"Study":
"You studied all night"
$ intelligence +=1
jump Daytime
"Play Music":
"You decided to play music"
$ charm +=1
"Sleep":
"You decided to go to sleep"
jump Daytime
Code: Select all
# Music button screen
screen music_button:
imagebutton: #the image button to play music and call start_music
idle "button.png"
xanchor 0.0
yanchor 0.0
xpos 100
ypos 100
action Call("start_music")
Code: Select all
#music script that plays music from a list at random
define audio.track1 = "audio/track1.ogg"
define audio.track2 = "audio/track2.ogg"
define audio.track3 = "audio/track3.ogg"
define audio.track4 = "audio/track4.ogg"
label start_music:
python:
playlist = [audio.track1, audio.track2, audio.track3, audio.track4]
renpy.random.shuffle(playlist)
play music playlist
return
Code: Select all
init python:
def start_music(playlist ):
renpy.random.shuffle(playlist)
renpy.music.play(playlist, loop=True)
# Notice, that I moved list of tracks outside of function, so you can provide different lists in different places
button action Function(start_music, [audio.track1, audio.track2, audio.track3, audio.track4])