dark lord Posted November 25, 2009 Share Posted November 25, 2009 Ho questo codice per le missioni, ma mi dà uno strano errore: Errore di script "Quests" sulla linea 314 del tipo 'NoMethodError' undefinited method 'picture_sprites' for #<Spriteset_Map:0x54f6a70> Cosa devo fare??? =begin=============================================================== Quests===============================================================--------------------------------------------------------------- Credits--------------------------------------------------------------- v 1.0 created by Sylaer created for Dark Sora sylaer@hotmail.it 05/12/2008--------------------------------------------------------------- Description--------------------------------------------------------------- [ITA] Questo script permette di gestire un sistema di missioni prendendo i dati di quest'ultime da un file sulla cartella del progetto in cui inserire le missioni. Accedendo alla scena Scene_Quests è possibile visualizzare queste missioni e vederne una loro breve descrizione. Le missioni si attivano con switch impostate sul file e si disattivano con delle altre switch anch'esse impostate sul file.--------------------------------------------------------------- Instructions--------------------------------------------------------------- [ITA] Basta creare un evento e aggiungere un call script con scritto: $scene = Scene_Quests.new Fatto questo bisogna impostare le missioni sul file specificato nella configuarazione qui sotto.---------------------------------------------------------------=end# ==============================================================================# Quest_Config module# ------------------------------------------------------------------------------# Modulo di configurazione per lo script Quests.# ==============================================================================module Quest_Conf # Questa impostazione indica il nome e il percorso del file delle missioni Quest_Data_Filename = "Data\\Quests.rxdata" # Con questa impostazione puoi modificare il font da utilizzare # per scrivere la descrizione delle missioni Desc_Font_Name = "Harrington" # Qui puoi impostare la grandezza del carattere per la descrizione # delle missioni Desc_Font_Size = 22 # Questa impostazione definisce la spaziatura tra le righe della descrizione Desc_Line_Width = 25 # Questa impostazione stabilisce la spaziatura tra i caratteri della # descizione Desc_Char_Spacing = 0 # Mettere questa impostazione a true se si vuole utilizzare lo script # all'interno del menu Return_to_Menu = true # Se l'impostazione precedente è a true allora impostare l'indice del comando # del menu dal quale si è lanciato questo script Menu_Index = 4end# ==============================================================================# RPG::Quest class# ------------------------------------------------------------------------------# Classe utilizzata per descrivere una missione# ==============================================================================module RPG class Quest attr_accessor :name attr_accessor :icon_name attr_accessor :switch_active attr_accessor :switch_completed attr_accessor :description #--------------------------------------------------------------------------- # * Metodo inizializzazione della classe #--------------------------------------------------------------------------- def initialize @name = "" @icon_name = "" @switch_active = 0 @switch_completed = 0 @description = "" end endend# ==============================================================================# Window_Quests_Description class# ------------------------------------------------------------------------------# Classe della finestra che visualizza la descrizione della missione# selezionata.# ==============================================================================class Window_Quests_Description < Window_Base ICON_HASH = {} ICON_HASH["sp"] = '001-Weapon01' ICON_HASH["co"]= '017-Accessory02' ICON_HASH["po"] = '021-Potion01' ICON_HASH["er"] = '025-Herb01' ICON_HASH["sa"] = '032-Item01' ICON_HASH["le"] = '033-Item02' ICON_HASH["pu"] = '049-Skill06' ICON_HASH["an"] = '016-Accessory01' ICON_HASH["pi"] = '035-Item04' ICON_HASH["gi"] = '002-Weapon02' ICON_HASH["ar"] = '005-Weapon05' ICON_HASH["cl"] = '007-Weapon07' ICON_HASH["sc"] = '009-Shield01' ICON_HASH["el"] = '010-Head01' ICON_HASH["cor"] = '014-Body02' #----------------------------------------------------------------------------- # * Hash di supporto per risolvere il problema della codifica #----------------------------------------------------------------------------- UTF_8_ENC = {} UTF_8_ENC[0xE0] = "à" UTF_8_ENC[0xE8] = "è" UTF_8_ENC[0xE9] = "é" UTF_8_ENC[0xEC] = "ì" UTF_8_ENC[0xF2] = "ò" UTF_8_ENC[0xF9] = "ù" #----------------------------------------------------------------------------- # * Metodo inizializzazione della finestra #----------------------------------------------------------------------------- def initialize(x,y,width,height) super(x,y,width,height) self.contents = Bitmap.new(self.width-32,self.height-32) end #----------------------------------------------------------------------------- # * Metodo che stampa sulla finestra la descrizione della missione #----------------------------------------------------------------------------- def refresh(quest) self.contents.clear return if quest.nil? self.contents.font.name = Quest_Conf::Desc_Font_Name self.contents.font.size = Quest_Conf::Desc_Font_Size text = quest.description.dup rect = Rect.new(0, 0, self.width / 2 - 32, 32) self.contents.fill_rect(rect, Color.new(0, 0, 0, 0)) bitmap = RPG::Cache.icon(ICON_HASH[quest.icon_name]) opacity = 255 self.contents.blt(0, 0 + 4, bitmap, Rect.new(0, 0, 24, 24), opacity) self.contents.draw_text(0 + 28, 0, 212, 32, quest.name) for i in 0..text.size-1 if UTF_8_ENC.include?(text[i]) text[i] = UTF_8_ENC[text[i]] end end y = 1.5 x = 32+16 words = [] word = "" max_x = self.width - 16 max_y = self.height - 16 while ((c = text.slice!(/./m)) != nil) word = word + c if c == " " words.push(word) word = "" end end words.push(word) for word in words if (x + word_size(word) + 32) >= max_x x = 32 y += 1 end while((c = word.slice!(/./m)) != nil) if (y * Quest_Conf::Desc_Line_Width) >= max_y return end if c == "\n" y += 1 x = 32 next end self.contents.draw_text(ox + x, oy+(Quest_Conf::Desc_Line_Width* y), 40, 32, c) x += self.contents.text_size©.width+Quest_Conf::Desc_Char_Spacing end end end #----------------------------------------------------------------------------- # * Metodo ausiliario per calcolare la lunghezza di una parola #----------------------------------------------------------------------------- def word_size(word) text = word.dup size = 0 while ((c = text.slice!(/./m)) != nil) size += self.contents.text_size©.width+Quest_Conf::Desc_Char_Spacing end return size endend# ==============================================================================# Window_Quests_Selection class# ------------------------------------------------------------------------------# Classe della finestra di selezione delle missioni# ==============================================================================class Window_Quests_Selection < Window_Selectable ICON_HASH = {} ICON_HASH["sp"] = '001-Weapon01' ICON_HASH["co"]= '017-Accessory02' ICON_HASH["po"] = '021-Potion01' ICON_HASH["er"] = '025-Herb01' ICON_HASH["sa"] = '032-Item01' ICON_HASH["le"] = '033-Item02' ICON_HASH["pu"] = '049-Skill06' ICON_HASH["an"] = '016-Accessory01' ICON_HASH["pi"] = '035-Item04' ICON_HASH["gi"] = '002-Weapon02' ICON_HASH["ar"] = '005-Weapon05' ICON_HASH["cl"] = '007-Weapon07' ICON_HASH["sc"] = '009-Shield01' ICON_HASH["el"] = '010-Head01' ICON_HASH["cor"] = '014-Body02' #-------------------------------------------------------------------------- # * Object Initialization # actor : actor #-------------------------------------------------------------------------- def initialize(x,quests) super(x,64,320,480-64) self.opacity = 0 @quests = quests @column_max = 1 refresh self.index = -1 end #-------------------------------------------------------------------------- # * Acquiring Skill #-------------------------------------------------------------------------- def quest_selected return @quests[self.index] end #-------------------------------------------------------------------------- # * Refresh #-------------------------------------------------------------------------- def refresh if self.contents != nil self.contents.dispose self.contents = nil end @item_max = @quests.size if @item_max > 0 self.contents = Bitmap.new(width - 32, row_max * 32) self.contents.font.name = Quest_Conf::Desc_Font_Name for i in 0...@item_max draw_item(i) end end end #-------------------------------------------------------------------------- # * Draw Item # index : item number #-------------------------------------------------------------------------- def draw_item(index) quest = @quests[index] x = 4 y = index * 32 rect = Rect.new(x, y, self.width / @column_max - 32, 32) self.contents.fill_rect(rect, Color.new(0, 0, 0, 0)) bitmap = RPG::Cache.icon(ICON_HASH[quest.icon_name]) self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24)) self.contents.draw_text(x + 28, y, 300, 32, quest.name) endend# ==============================================================================# Window_Quests_Header class# ------------------------------------------------------------------------------# Classe della finestra che stampa i descrittori dei due tipi di missioni# ==============================================================================class Window_Quests_Header < Window_Base #----------------------------------------------------------------------------- # * Metodo inizializzazione della finestra #----------------------------------------------------------------------------- def initialize(x,y,width,height) super(x,y,width,height) self.contents = Bitmap.new(self.width-32, self.height-32) refresh end #----------------------------------------------------------------------------- # * Metodo che stampa i descrittori missioni principali e secondarie #----------------------------------------------------------------------------- def refresh self.contents.font.name = Quest_Conf::Desc_Font_Name self.contents.font.size = Quest_Conf::Desc_Font_Size self.contents.draw_text(0+32,-16,320,64,"Missioni Principali") self.contents.draw_text(320+32,-16,320,64,"Missioni Secondarie") endend# ==============================================================================# Scene_Quests class# ------------------------------------------------------------------------------# Classe Principale dello script che gestisce le finestre di selezione e di# descrizione delle missioni.# ==============================================================================class Scene_Quests #----------------------------------------------------------------------------- # * Classe di appoggio che ospita i dati delle missioni #----------------------------------------------------------------------------- class Quests attr_accessor :main_quests attr_accessor :sec_quests def intialize @main_quests = [] @sec_quests = [] end end #----------------------------------------------------------------------------- # * Metodo principale della scena #----------------------------------------------------------------------------- def main @spriteset = Spriteset_Map.new for i in 1..50 next if @spriteset.picture_sprites[i].nil? @spriteset.picture_sprites[i].dispose end @data = extract_data_from_file(Quest_Conf::Quest_Data_Filename) @header_window = Window_Quests_Header.new(0,0,640,64) @dummy_window = Window_Base.new(0,64,640,480-64) @selection_main_quests_window = Window_Quests_Selection.new(0,@data.main_quests) @selection_main_quests_window.index = 0 if @data.main_quests.size != 0 if @data.main_quests.size != 0 @main_quest_selector_active = true elsif @data.sec_quests.size != 0 @main_quest_selector_active = false else @main_quest_selector_active = nil end @selection_sec_quests_window = Window_Quests_Selection.new(320,@data.sec_quests) if @data.sec_quests.size != 0 && @data.main_quests.size == 0 @selection_sec_quests_window.index = 0 end @selection_sec_quests_window.active = false @description_window = Window_Quests_Description.new(0,180,640,300) @description_window.visible = false @description_window.active = false @description_window.z = 300 Graphics.transition loop do Graphics.update Input.update update if $scene != self break end end Graphics.freeze @spriteset.dispose @header_window.dispose @dummy_window.dispose @selection_main_quests_window.dispose @selection_sec_quests_window.dispose @description_window.dispose end #----------------------------------------------------------------------------- # * Metodo di aggiornamento della scena #----------------------------------------------------------------------------- def update if Input.trigger?(Input::B) && @description_window.active == false $game_system.se_play($data_system.cancel_se) $scene = Quest_Conf::Return_to_Menu ? Scene_Menu.new(Quest_Conf::Menu_Index) : Scene_Map.new return end return if @main_quest_selector_active.nil? selection_main_quests_window_update if @selection_main_quests_window.active selection_sec_quests_window_update if @selection_sec_quests_window.active description_window_update if @description_window.active end def selection_sec_quests_window_update @selection_sec_quests_window.update if Input.trigger?(Input::LEFT) $game_system.se_play($data_system.cursor_se) return if @data.main_quests.size == 0 if @selection_sec_quests_window.index >= @data.main_quests.size - 1 @selection_main_quests_window.index = @data.main_quests.size - 1 @selection_sec_quests_window.index = -1 else @selection_main_quests_window.index = @selection_sec_quests_window.index @selection_sec_quests_window.index = -1 end @selection_main_quests_window.active = true @selection_sec_quests_window.active = false @main_quest_selector_active = true return end if Input.trigger?(Input::C) quest = @selection_sec_quests_window.quest_selected if quest.nil? $game_system.se_play($data_system.buzzer_se) return end $game_system.se_play($data_system.decision_se) @selection_sec_quests_window.active = false @description_window.refresh(quest) @description_window.active = true @description_window.visible = true return end end #----------------------------------------------------------------------------- # * Metodo di aggiornamento specifico della finestra di selezione #----------------------------------------------------------------------------- def selection_main_quests_window_update @selection_main_quests_window.update if Input.trigger?(Input::RIGHT) $game_system.se_play($data_system.cursor_se) return if @data.sec_quests.size == 0 if @selection_main_quests_window.index >= @data.sec_quests.size - 1 @selection_sec_quests_window.index = @data.sec_quests.size - 1 @selection_main_quests_window.index = -1 else @selection_sec_quests_window.index = @selection_main_quests_window.index @selection_main_quests_window.index = -1 end @selection_sec_quests_window.active = true @selection_main_quests_window.active = false @main_quest_selector_active = false return end if Input.trigger?(Input::C) quest = @selection_main_quests_window.quest_selected if quest.nil? $game_system.se_play($data_system.buzzer_se) return end $game_system.se_play($data_system.decision_se) @selection_main_quests_window.active = false @description_window.refresh(quest) @description_window.active = true @description_window.visible = true return end end #----------------------------------------------------------------------------- # * Metodo di aggiornamento specifico della finestra di descrizione #----------------------------------------------------------------------------- def description_window_update @description_window.update if Input.trigger?(Input::B) $game_system.se_play($data_system.cancel_se) @description_window.visible = false @description_window.active = false if @main_quest_selector_active @selection_main_quests_window.active = true else @selection_sec_quests_window.active = true end return end end #----------------------------------------------------------------------------- # * Metodo ausiliario che estrae i dati dalle missioni dal file specificato #----------------------------------------------------------------------------- def extract_data_from_file(filename) quests = Quests.new quests.main_quests = [] quests.sec_quests = [] file = File.open(filename) str = file.read while(c=str.slice!(/[#].+/)) end quests_data = [] while(c=str.slice!(/[$].*?[$]/m)) quests_data.push© end for q in quests_data name,type,icon_name,switch_a,switch_c,desc = nil q.scan(/[$].*?["](.*?)["].*?[,].*?([0-9]+).*?[,].*?["](.*?)["].*?[,].*?([0-9]+).*?[,].*?([0-9]+).*?[,].*?["](.*?)["].*?[$]/m){ name = $1 type = $2.to_i icon_name = $3 switch_a = $4.to_i switch_c = $5.to_i desc = $6} if name.nil? next end if !$game_switches[switch_a] next elsif !$game_switches[switch_c] next end quest = RPG::Quest.new quest.name = name quest.icon_name = icon_name quest.switch_active = switch_a quest.switch_completed = switch_c quest.description = desc if type==0 quests.main_quests.push(quest) else quests.sec_quests.push(quest) end end return quests endend Link to comment Share on other sites More sharing options...
Kingartur2 Posted November 25, 2009 Share Posted November 25, 2009 Aggiungi questa riga in fondo dopo l'ultimo endclass Spriteset_Mapattr_accessor :picture_spritesend Per qualsiasi motivo non aprite questo spoiler. Ho detto di non aprirlo ! Se lo apri ancora esplode il mondo. Aaaaaa è un vizio. Contento? Il mondo è esploso, sono tutti morti per colpa della tua curiosità . Vuoi che ti venga anche il morbillo, la varicella e l'AIDS??? O bravo ora sei un malato terminale e nessuno ti puo curare, sono tutti morti ! Se clicchi ancora una volta il PC esplode. E dai smettila !! Uff!! Hai cliccato tante volte che ho dovuto sostituirlo con un codebox. http://s8.postimg.org/yntv9nxld/Banner.png http://img204.imageshack.us/img204/8039/sccontest3octpl3.gif Link to comment Share on other sites More sharing options...
lupins Posted March 18, 2010 Share Posted March 18, 2010 mi spiegate come funziona lo script perchè qnd kiamo loscript mi si blocca il gioco SE LA MEMORIA NON MI INGANNA, E MI INGANNA SPESSO... Link to comment Share on other sites More sharing options...
Astro86 Posted March 20, 2010 Share Posted March 20, 2010 Non dovrebbe stare nella sezione Supporto RGSS (XP) questi tipi di topic? Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now