Lol at topic name.
I know I said I'll never script again, but I couldn't help myself from making this.
class Jukebox
attr_reader :list
def initialize
@songs = Dir.entries("Audio/BGM/")
temp = @songs.clone
@list = []
for i in 0..(temp.size)
next if temp[i] == "." or temp[i] == ".." or temp[i] == nil
@list.push(temp[i])
end
for i in 0..(@list.size)
@list[i].gsub!(/\.[^\.]*\Z/) {|s| "" }
end
end
def find(song)
@list.each.do(|i| return i.index if i == song)
end
def play(song)
index = find(song)
Audio.bgm_play(@songs[index + 2], 100, 100)
end
def stop
Audio.bgm_stop
end
end
It is the flesh of a Radio/Jukebox.
All you need to do is script the bone.
Erm, let me speak English here.
All you need to do is script a scene that will utilize this in the game, allowing the player to choose songs to play as the bgm.
NOTE: This will only work for songs that have been imported!!!!
INSTRUCTIONS: The only ones that should use this should be those with the understanding of how it works. Making the music list shouldn't be too hard. $jukebox.list anyone?
To play a song, you would doj $jukebox.play("EXACT SONG NAME MINUS EXTENSION IN QUOTES").
Oh yeah, you'll also need to initialize $jukebox as an instance of the Jukebox class.
i.e. :
$jukebox = Jukebox.new
EDIT : Fixed error pointed out by Zeriab.