ID:271649
 
Hello,
The Name is Rentu. I've just recently started coding. Though im not completely stupid when it comes to it i have had a Year of Javaa and a few classes of C++. I was just wondering if someone could give a code that picks a random song from a list to play when someone logs in. Then if they log out and log in again a new song would play, hence it being random. Also, a song playlist gives the users a command to pick a song from a list that the game has provided to play to them selfs. I'd greatly appreciate it, if someone could help me out here.

Thank you.
mob/Login() // Login Proc
var/music = rand(0,3) //define the varible and make it random each time
switch(music) //switch in order not to use block code
if(1) //checks the value of the var
src << 'lalal.wav' //plays the music
if(2) //checks the value of the var
src << 'lalal2.wav' //plays the music
else //if its not 1 or 2
src << 'lalala3.wav' //plays the music


Thats baisically a random music system please do learn from it and not copy and paste it though if you dont want to override your original Login() proc, use the ..()

- Miran94
mob/var/list/songs = list('song1.mid','song2.mid','song3.mid')

mob
Login()
..()
src << pick(songs)
verb/Pick_Song()
var/song = input("Which song?")in songs
usr << song


That should do what you need, can't check right now but I'm pretty sure storing files within a list works like that.