Sujet: [VX] Système de Radio Ven 2 Mar 2012 - 23:48
Nom du script : Radio
Auteur : Jet10985 ou Jet
Ce script permet de créés une radio dans votre jeu.
le script
Spoiler:
Code:
#=============================================================================== # 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", "2:46"] RADIO_SONGS[1] = ["SONG 2", "2:46"] RADIO_SONGS[2] = ["SONG 3", "2:46"] RADIO_SONGS[3] = ["SONG 4", "2:46"] RADIO_SONGS[4] = ["SONG 5", "2:46"] RADIO_SONGS[5] = ["SONG 6", "2:46"] RADIO_SONGS[6] = ["SONG 7", "2:46"] RADIO_SONGS[7] = ["SONG 8", "2:46"] RADIO_SONGS[8] = ["SONG 9", "2:46"] RADIO_SONGS[9] = ["SONG 10", "2:46"] RADIO_SONGS[10] = ["SONG 11", "2:46"]
# Below is the config for different radio stations. # The config follows the following format: # RADIO_STATIONS["Name of Station"] RADIO_STATIONS["Radio 1"] = [0, 1, 2, 5] RADIO_STATIONS["Radio 2"] = [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 = ["Radio 1", "Radio 2"]
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
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 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
Dans ce scripte ce propose a vous trois commende de script
la première : new_station(name) qui vous permet de crée une nouvelle station (replacé name par le nom choisie)
la seconde : stop_radio qui vous permet d'arrêté la radio
la dernière : $scene = Scene_Radio.new qui permet d'ouvrir le menus de la radio
# These are what stations are already unlocked by default. # These names HAVE TO BE EXACTLY WHAT YOU NAMED THE STATIONS ABOVE! STATIONS_AUTOMATICALLY_UNLOCKED = ["Radio 1", "Radio 2"]
sur la première et deuxième ligne se trouvent les noms des stations de radio puis les chiffre à la fin des lignes sont les musiques que passent les radios les musiquent sont a métré dans le dossier BGS
Une image ingame
Spoiler:
démos http://www.sendspace.com/file/aji19z
guillaumeducrotoy
Va-nu-pieds Lv.4
Age : 35 Inscrit le : 14/10/2010 Messages : 59
Sujet: Re: [VX] Système de Radio Mar 7 Aoû 2012 - 12:35
Bonjour, ton script ne marche pas. Quand je veux l'utiliser il me met un message d'erreur:
Line 202 SyntaxError occurred Voci la ligne en question (en rouge)
@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
Zangther
Maître des Duels
Age : 32 Inscrit le : 29/07/2009 Messages : 7841
Sujet: Re: [VX] Système de Radio Mar 7 Aoû 2012 - 12:39
Remplace cette ligne par @help_window.set_text("Current Station: #{$game_radio.playing_station}", 1)
guillaumeducrotoy
Va-nu-pieds Lv.4
Age : 35 Inscrit le : 14/10/2010 Messages : 59
Sujet: Re: [VX] Système de Radio Mar 7 Aoû 2012 - 12:59
quand je fais news station il me met ca [img][/img]
guillaumeducrotoy
Va-nu-pieds Lv.4
Age : 35 Inscrit le : 14/10/2010 Messages : 59
Sujet: Re: [VX] Système de Radio Mar 7 Aoû 2012 - 13:09
Je n'arrive pas à accéder à ta démo.
guillaumeducrotoy
Va-nu-pieds Lv.4
Age : 35 Inscrit le : 14/10/2010 Messages : 59
Sujet: Re: [VX] Système de Radio Mar 7 Aoû 2012 - 14:24
Je n'arrive pas à accéder à ta démo.
j'ai mis des guillemet et il me met ca
la ligne en question def random_song station = RADIO_STATIONS[@playing_station] song = RADIO_SONGS[station[rand(station.size)]] @song_index = song return song[0]
guillaumeducrotoy
Va-nu-pieds Lv.4
Age : 35 Inscrit le : 14/10/2010 Messages : 59
Sujet: Re: [VX] Système de Radio Mar 7 Aoû 2012 - 14:41
#=============================================================================== # 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] = ["02 Piste 2", "5:52"] RADIO_SONGS[1] = ["SONG 2", "2:46"] RADIO_SONGS[2] = ["SONG 3", "2:46"] RADIO_SONGS[3] = ["SONG 4", "2:46"] RADIO_SONGS[4] = ["SONG 5", "2:46"] RADIO_SONGS[5] = ["SONG 6", "2:46"] RADIO_SONGS[6] = ["SONG 7", "2:46"] RADIO_SONGS[7] = ["SONG 8", "2:46"] RADIO_SONGS[8] = ["SONG 9", "2:46"] RADIO_SONGS[9] = ["SONG 10", "2:46"] RADIO_SONGS[10] = ["SONG 11", "2:46"]
# Below is the config for different radio stations. # The config follows the following format: # RADIO_STATIONS["Name of Station"] RADIO_STATIONS["Radio 1"] = [0, 1, 2, 5] RADIO_STATIONS["Radio 2"] = [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 = ["Radio 1", "Radio 2"]
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
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 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
Voici le script tel qu'il estdans mon jeu. Peux tu m'aider?