#=============================================================================== # Radio # By Jet10985 (Jet) #=============================================================================== # This script will allow you to have a radio in your game. This means players # can tune into radio stations and listen to random audio tracks. # This script has: 3 customization option. #=============================================================================== # Overwritten Methods: # None #------------------------------------------------------------------------------- # Aliased methods: # Scene_Title: create_game_objects # Scene_Base: update # Game_System: initialize #=============================================================================== =begin How to unlock new stations: to give the player a new station to listen to, use the following code in an event "Script..." command: new_station(name) name = THE EXACT NAME (puncuation like caps, commas and such must be the same) of a station created in the config below. -------------------------------------------------------------------------------- How to stop the Radio: to stop the radio (for like, an event or something), use the following code in an event "Script..." command: stop_radio -------------------------------------------------------------------------------- Calling the radio: To call up the radio screen, enter this in an event "Script..." command: $scene = Scene_Radio.new =end module JetRadio RADIO_SONGS = [] # Don't Touch RADIO_STATIONS = {} # Don't touch # Below is the config for songs that can be played on certain stations. # The config follows the following format: # RADIO_SONGS[next_index] = ["Song name", "song length"] # next_index is just the next number in the sequence. See Examples. # "Song name" is the song name (duh!) make sure it s in quotes. # "song length" is the song length (again, DUH!) it needs to be like this: # "minutes:seconds" See examples. RADIO_SONGS[0] = ["SONG 1", "4:02"] RADIO_SONGS[1] = ["SONG 2", "8:46"] RADIO_SONGS[2] = ["SONG 3", "0:41"] RADIO_SONGS[3] = ["SONG 4", "2:32"] RADIO_SONGS[4] = ["SONG 5", "12:45"] RADIO_SONGS[5] = ["SONG 6", "0:32"] RADIO_SONGS[6] = ["SONG 7", "54:00"] RADIO_SONGS[7] = ["SONG 8", "4:59"] # Below is the config for different radio stations. # The config follows the following format: # RADIO_STATIONS["Name of Station"] RADIO_STATIONS["Some Stuff"] = [0, 1, 2] RADIO_STATIONS["More Stuff"] = [7, 4, 5, 6, 3] # These are what stations are already unlocked by default. # These names HAVE TO BE EXACTLY WHAT YOU NAMED THE STATIONS ABOVE! STATIONS_AUTOMATICALLY_UNLOCKED = ["Some Stuff", "More Stuff"] end #=============================================================================== # DON'T EDIT FURTHER UNLESS YOU KNOW WHAT TO DO. #=============================================================================== class Scene_Title alias jet4682_create_game_objects create_game_objects unless $@ def create_game_objects jet4682_create_game_objects $game_radio = Game_Radio.new end end class Scene_Base alias jet1111_update update unless $@ def update jet1111_update $game_radio.update unless $game_radio.nil? end end class Game_System attr_accessor :unlocked_stations alias jet6482_initialize initialize unless $@ def initialize jet6482_initialize @unlocked_stations = ["Turn off Radio"] + JetRadio::STATIONS_AUTOMATICALLY_UNLOCKED end end class Game_Interpreter def stop_radio RPG::BGS.stop if !$game_radio.playing_song.nil? $game_radio.playing_song = nil $game_radio.playing_station = nil end def new_station(name) $game_system.unlocked_stations.push(name) end end class Game_Radio include JetRadio attr_accessor :playing_station attr_accessor :playing_song attr_accessor :song_playing_for attr_accessor :song_index def initialize @playing_station = nil @playing_song = nil @song_playing_for = 0 @song_index = [] end def update if !@playing_song.nil? && !@playing_station.nil? update_playing_song end end def playing_song_length minutes = @song_index[1].split(":")[0].to_i * 60 seconds = @song_index[1].split(":")[1].to_i return minutes + seconds end def random_song station = RADIO_STATIONS[@playing_station] song = RADIO_SONGS[station[rand(station.size)]] @song_index = song return song[0] end def update_playing_song @song_playing_for += 1 if @song_playing_for == playing_song_length * 60 RPG::BGS.stop @playing_song = RPG::BGS.new(random_song, 80, 100) @playing_song.play end end def change_station(station) if station.nil? RPG::BGS.stop if !@playing_song.nil? @playing_song = nil @playing_station = nil elsif @playing_station != station RPG::BGS.stop if @playing_song != nil @playing_station = station @playing_song = RPG::BGS.new(random_song, 80, 100) @playing_song.play end end def stop_radio RPG::BGS.stop if !@playing_song.nil? @playing_song = nil @playing_station = nil end end class Scene_Radio < Scene_Base def initialize @came_from = $scene.class.to_s end def start super @help_window = Window_Help.new if $game_radio.playing_station.nil? @help_window.set_text("Current Station: Radio is Off.", 1) else @help_window.set_text("Current Station: " + $game_radio.playing_station, 1) end create_menu_background create_command_window end def create_command_window @command_window = Window_Command.new(170, $game_system.unlocked_stations) @command_window.x = Graphics.width / 2 - @command_window.width / 2 @command_window.y = Graphics.height / 2 - @command_window.height / 2 end def update_command_window @command_window.update if Input.trigger?(Input::B) Sound.play_cancel return_scene elsif Input.trigger?(Input::C) if @command_window.index == 0 $game_radio.change_station(nil) @help_window.set_text("Current Station: Radio is Off.", 1) else $game_radio.change_station( @command_window.commands[@command_window.index]) @help_window.set_text("Current Station: " + $game_radio.playing_station, 1) end end end def return_scene eval("$scene = #{@came_from}.new()") end def update super update_menu_background update_command_window end def terminate super dispose_menu_background @command_window.dispose @help_window.dispose end end