Bob423 52 Report post Posted June 1, 2014 I've managed to show the name and level of the first actor in the party as well as the default name of a specific actor. What I want though, is to display the current name of a specific actor regardless of whether or not they're in the party. When I thought of this, it seemed like the easiest way to use save file names. When the player chooses New Game, they are shown a name input window and type in the name of their save file. I'm using Cyclope's Advanced Name Input script with a few edits to make it look better and stuff. This is my Window_SaveFile #============================================================================== # ** Window_SaveFile #------------------------------------------------------------------------------ # This window displays save files on the save and load screens. #============================================================================== class Window_SaveFile < Window_Base #-------------------------------------------------------------------------- # * Public Instance Variables #-------------------------------------------------------------------------- attr_reader :filename # file name attr_reader :selected # selected #-------------------------------------------------------------------------- # * Object Initialization # file_index : save file index (0-3) # filename : file name #-------------------------------------------------------------------------- def initialize(file_index, filename) super(0, 64 + file_index % 4 * 104, 640, 104) self.contents = Bitmap.new(width - 32, height - 32) @file_index = file_index @filename = "Saves/ArcatisSave#{@file_index + 1}.rxdata" @time_stamp = Time.at(0) @file_exist = FileTest.exist?(@filename) if @file_exist file = File.open(@filename, "r") @time_stamp = file.mtime @characters = Marshal.load(file) @frame_count = Marshal.load(file) @game_system = Marshal.load(file) @game_switches = Marshal.load(file) @game_variables = Marshal.load(file) @data_actors = Marshal.load(file) @game_actor = Marshal.load(file) @total_sec = @frame_count / Graphics.frame_rate file.close end refresh @selected = false end #-------------------------------------------------------------------------- # * Refresh #-------------------------------------------------------------------------- def refresh self.contents.clear # Draw file number self.contents.font.color = normal_color # name = "File #{@file_index + 1}" actor = $data_actors[10] name = actor.name.to_s self.contents.draw_text(4, 0, 600, 32, name) @name_width = contents.text_size(name).width # If save file exists if @file_exist # Draw character for i in 0...@characters.size bitmap = RPG::Cache.character(@characters[i][0], @characters[i][1]) cw = bitmap.rect.width / 4 ch = bitmap.rect.height / 4 src_rect = Rect.new(0, 0, cw, ch) x = 308 - @characters.size * 32 + i * 56 - cw / 2 self.contents.blt(x, 68 - ch, bitmap, src_rect) end # Draw actor 1's name characters_name = @characters[0][2] self.contents.draw_text(-60, -5, 600, 32, characters_name.to_s, 2) # Draw Actor 1's level actors_level = @characters[0][3] self.contents.font.color = system_color self.contents.draw_text(-22, -5, 600, 32, "Lv.", 2) self.contents.font.color = normal_color self.contents.draw_text(4, -5, 600, 32, actors_level.to_s, 2) # Draw play time hour = @total_sec / 60 / 60 min = @total_sec / 60 % 60 sec = @total_sec % 60 time_string = sprintf("%02d:%02d:%02d", hour, min, sec) self.contents.font.color = normal_color self.contents.draw_text(4, 20, 600, 32, time_string, 2) # Draw timestamp self.contents.font.color = normal_color time_string = @time_stamp.strftime("%Y/%m/%d %H:%M") self.contents.draw_text(4, 45, 600, 32, time_string, 2) end end #-------------------------------------------------------------------------- # * Set Selected # selected : new selected (true = selected, false = unselected) #-------------------------------------------------------------------------- def selected=(selected) @selected = selected update_cursor_rect end #-------------------------------------------------------------------------- # * Cursor Rectangle Update #-------------------------------------------------------------------------- def update_cursor_rect if @selected self.cursor_rect.set(0, 0, @name_width + 8, 32) else self.cursor_rect.empty end end end Right now, it shows this: Share this post Link to post Share on other sites
Moonpearl 32 Report post Posted June 2, 2014 You gotta get your hands a bit dirtier to achieve that. The thing is, the system doesn't read deep into the save data - it actually stores the few pieces of information it requires to dispay the load/save screen as the header of the save file. You can get any further information by actually reading the entire data and then taking what you need. Basically you should look into the loading process and see how they retrieve the actors' data, then treat them as a temporary version of the $game_party variable, from which you can extract any information you want. I might come up with an actual piece of code later if I can find some time. Share this post Link to post Share on other sites
Bob423 52 Report post Posted June 2, 2014 Hm...well, I'll give it a try. thanks :D Share this post Link to post Share on other sites
Bigace360 38 Report post Posted June 3, 2014 Try this bob, I haven't tested it so it might have errors or just not work properly; but give it a try any ways see how it plays. =begin Instructions -to open the name scene for the savename, call the script from an event with: savename_change(max_char) max_char = the amount of character that is allow in the name of the save file. -Also if you want, go to Game_System below and add a default save filename to @savename = '' =end #■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■class Game_System attr_accessor :savename alias :bobsavenamechanger_init :initialize unless $@ def initialize bobsavenamechanger_init @savename = '' end end #■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■class Interpreter def savename_change(max_char) $game_temp.name_max_char = max_char $scene = Scene_SaveNameChanger.new @index += 1 return false end end #■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■class Window_SaveFile < Window_Base def refresh contents.clear contents.font.color = normal_color name = "#{$game_system.savename} #{@file_index + 1}" contents.draw_text(4, 0, 600, 32, name) @name_width = contents.text_size(name).width # If save file exists if @file_exist # Draw character for i in 0...@characters.size bitmap = RPG::Cache.character(@characters[i][0], @characters[i][1]) cw = bitmap.rect.width / 4 ch = bitmap.rect.height / 4 src_rect = Rect.new(0, 0, cw, ch) x = 308 - @characters.size * 32 + i * 56 - cw / 2 self.contents.blt(x, 68 - ch, bitmap, src_rect) end # Draw actor 1's name characters_name = @characters[0][2] self.contents.draw_text(-60, -5, 600, 32, characters_name.to_s, 2) # Draw Actor 1's level actors_level = @characters[0][3] self.contents.font.color = system_color self.contents.draw_text(-22, -5, 600, 32, "Lv.", 2) self.contents.font.color = normal_color self.contents.draw_text(4, -5, 600, 32, actors_level.to_s, 2) # Draw play time hour = @total_sec / 60 / 60 min = @total_sec / 60 % 60 sec = @total_sec % 60 time_string = sprintf("%02d:%02d:%02d", hour, min, sec) self.contents.font.color = normal_color self.contents.draw_text(4, 20, 600, 32, time_string, 2) # Draw timestamp self.contents.font.color = normal_color time_string = @time_stamp.strftime("%Y/%m/%d %H:%M") self.contents.draw_text(4, 45, 600, 32, time_string, 2) end end end #■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■Window_SaveNameEdit = Window_NameEdit.dup class Window_SaveNameEdit < Window_Base def initialize(max_char) super(0, 0, 640, 128) self.contents = Bitmap.new(width - 32, height - 32) @name = $game_system.savename @max_char = max_char name_array = @name.split(//)[0...@max_char] @name = "" name_array.size.times {|i| @name += name_array[i]} @default_name = @name @index = name_array.size refresh update_cursor_rect end def refresh contents.clear name_array = @name.split(//) @max_char.times do |i| c = name_array[i] c = "_" if c.nil? x = 320 - @max_char * 14 + i * 28 contents.draw_text(x, 32, 28, 32, c, 1) end end end #■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■Scene_SaveNameChanger = Scene_Name.dup class Scene_SaveNameChanger def main @actor = $game_actors[$game_temp.name_actor_id] @edit_window = Window_NameEdit.new(@actor, $game_temp.name_max_char) @input_window = Window_NameInput.new Graphics.transition loop {Graphics.update; Input.update; update; break if $scene != self} Graphics.freeze @edit_window.dispose @input_window.dispose end end Share this post Link to post Share on other sites
Bob423 52 Report post Posted June 3, 2014 (edited) I'm not surprised it's incompatible with the advanced name_input script I'm using, and I kinda need a name input system that lets the player type the name instead of using a stupid name input thing with the arrow keys like every console game before USB keyboards, Wii Remotes, and touch screens. This is the script, with the edits i've made. #============================================================================== # Modyfied Scene_Name # By Cyclope #------------------------------------------------------------------------------ #´ Instructions # Place above main #------------------------------------------------------------------------------ # Credit: # Nattmath (For making Scene_Name Leters Modification) # Blizzard (For making Custom Cotrols) # Cyclope (For modifying Scene_Name Leters Modification and Scene_Name) #============================================================================== #============================================================================== # ** Window_Instructions #------------------------------------------------------------------------------ # This window displays full status specs on the status screen. #============================================================================== class Window_Instruction < Window_Base #-------------------------------------------------------------------------- # * Object Initialization # actor : actor #-------------------------------------------------------------------------- def initialize super( 0, 400, 640, 80) self.contents = Bitmap.new(width - 32, height - 32) refresh end #-------------------------------------------------------------------------- # * Refresh #-------------------------------------------------------------------------- def refresh self.contents.clear self.contents.font.name = "Arial" self.contents.font.size = 24 self.contents.font.color = normal_color # Change this text to whatever instructions u want to have! self.contents.draw_text(50, 0, 500, 32, "Enter/Return: Confirm", 1) end end #============================================================================== # ** Window_TextName #------------------------------------------------------------------------------ # super ( 224, 32, 224, 80) #============================================================================== class Window_TextName < Window_Base def initialize super (160, 32, 320, 90) self.contents = Bitmap.new(width - 32, height - 32) @actor = $game_actors[$game_temp.name_actor_id] refresh end def refresh self.contents.clear draw_actor_graphic(@actor, 20, 48) self.contents.font.name = "Arial" self.contents.font.size = 40 self.contents.font.color = normal_color self.contents.draw_text(-16, 0, 320, 40, "Input Save File Name:", 1) end end #============================================================================== # ** Window_NameEdit #------------------------------------------------------------------------------ # This window is used to edit your name on the input name screen. #============================================================================== class Window_NameEdit < Window_Base #-------------------------------------------------------------------------- # * Object Initialization # actor : actor # max_char : maximum number of characters #-------------------------------------------------------------------------- def initialize(actor, max_char) super(16, 200, 608, 96) self.contents = Bitmap.new(width - 32, height - 32) @actor = actor @name = actor.name @max_char = max_char # Fit name within maximum number of characters name_array = @name.split(//)[0...@max_char] @name = "" for i in 0...name_array.size @name += name_array[i] end @default_name = @name @index = name_array.size refresh update_cursor_rect end #-------------------------------------------------------------------------- # * Return to Default Name #-------------------------------------------------------------------------- def restore_default @name = @default_name @index = @name.split(//).size refresh update_cursor_rect end #-------------------------------------------------------------------------- # * Add Character # character : text character to be added #-------------------------------------------------------------------------- def add(character) if @index < @max_char and character != "" @name += character @index += 1 refresh update_cursor_rect end end #-------------------------------------------------------------------------- # * Delete Character #-------------------------------------------------------------------------- def back if @index > 0 # Delete 1 text character name_array = @name.split(//) @name = "" for i in 0...name_array.size-1 @name += name_array[i] end @index -= 1 refresh update_cursor_rect end end #-------------------------------------------------------------------------- # * Refresh #-------------------------------------------------------------------------- def refresh self.contents.clear # Draw name self.contents.font.size = 42 name_array = @name.split(//) for i in 0...@max_char c = name_array[i] if c == nil c = "" end x = 304 - @max_char * 14 + i * 26 self.contents.draw_text(x, 15, 28, 42, c, 1) end end #-------------------------------------------------------------------------- # * Cursor Rectangle Update #-------------------------------------------------------------------------- def update_cursor_rect x = 320 - @max_char * 14 + @index * 26 self.cursor_rect.set(x-12, 55, 20, 5) end #-------------------------------------------------------------------------- # * Frame Update #-------------------------------------------------------------------------- def update super update_cursor_rect end end #============================================================================== # ** Window_NameInput #------------------------------------------------------------------------------ # This window is used to select text characters on the input name screen. #============================================================================== class Window_NameInput < Window_Base CHARACTER_TABLE = [ "", "" ] #-------------------------------------------------------------------------- # * Object Initialization #-------------------------------------------------------------------------- def initialize super(0, 114, 640, 0) self.contents = Bitmap.new(width - 32, height - 32) @index = 0 refresh end #-------------------------------------------------------------------------- # * Text Character Acquisition #-------------------------------------------------------------------------- def character return CHARACTER_TABLE[@index] end #-------------------------------------------------------------------------- # * Refresh #-------------------------------------------------------------------------- def refresh self.contents.clear end #-------------------------------------------------------------------------- # * Frame Update #-------------------------------------------------------------------------- def update super end end #============================================================================== # ** Scene_Name #------------------------------------------------------------------------------ # This class performs name input screen processing. #============================================================================== class Scene_Name #-------------------------------------------------------------------------- # * Main Processing #-------------------------------------------------------------------------- def main # Get actor @actor = $game_actors[$game_temp.name_actor_id] # Make windows @edit_window = Window_NameEdit.new(@actor, $game_temp.name_max_char) @edit_window.back_opacity = 160 @input_window = Window_NameInput.new @inst_window = Window_Instruction.new #@inst_window.back_opacity = 160 @inst_window.opacity = 0 @nametext_window = Window_TextName.new #@nametext_window.back_opacity = 160 @nametext_window.opacity = 0 @spriteset = Spriteset_Map.new # Execute transition Graphics.transition # Main loop loop do # Update game screen Graphics.update # Update input information Input.update # Frame update update # Abort loop if screen is changed if $scene != self break end end # Prepare for transition Graphics.freeze # Dispose of windows @edit_window.dispose @input_window.dispose @inst_window.dispose @nametext_window.dispose @spriteset.dispose end #-------------------------------------------------------------------------- # * Frame Update #-------------------------------------------------------------------------- def update # Update windows @edit_window.update @input_window.update @nametext_window.update @inst_window.update # If C button was pressed if Input.trigger?(Input::C) # If cursor position is at [OK] if @input_window.character == nil # If name is empty if @edit_window.name == "" # If name is empty if @edit_window.name == "" # Play buzzer SE $game_system.se_play($data_system.buzzer_se) return end # Play decision SE $game_system.se_play($data_system.decision_se) return end # Change actor name @actor.name = @edit_window.name # Play decision SE $game_system.se_play($data_system.decision_se) # Switch to map screen $scene = Scene_Map.new return end # If cursor position is at maximum if @edit_window.index == $game_temp.name_max_char # Play buzzer SE $game_system.se_play($data_system.buzzer_se) return end # If text character is empty if @input_window.character == "" # Play buzzer SE $game_system.se_play($data_system.buzzer_se) return end # Play decision SE $game_system.se_play($data_system.decision_se) # Add text character @edit_window.add(@input_window.character) return end end end #============================================================================== # ** Scene_Name Leters Modification Made By Nattmath and Improved Cyclope #------------------------------------------------------------------------------ # Makes you imput stuf with the keyboard #============================================================================== class Scene_Name alias name_input_update update def update (65...91).each{|i| if Input.trigger?(i) $game_system.se_play($data_system.decision_se) let = Input::Key.index(i) let = let.downcase unless Input.press?(Input::Key['Shift']) @edit_window.add(let) end} (48...58).each{|i| if Input.trigger?(i) $game_system.se_play($data_system.decision_se) let = Input::Key.index(i) @edit_window.add(let) end} (186...192).each{|i| if Input.trigger?(i) $game_system.se_play($data_system.decision_se) let = Input::Key.index(i) @edit_window.add(let) end} (219...222).each{|i| if Input.trigger?(i) $game_system.se_play($data_system.decision_se) let = Input::Key.index(i) @edit_window.add(let) end} if Input.trigger?(Input::Key['Backspace']) @edit_window.back end if Input.trigger?(Input::Key['Arrow Left']) @edit_window.back end if Input.trigger?(Input::Key['Enter']) # If name is empty if @edit_window.name == "" # Return to default name @edit_window.restore_default # If name is empty if @edit_window.name == "" # Play buzzer SE $game_system.se_play($data_system.buzzer_se) return end # Play decision SE $game_system.se_play($data_system.decision_se) return end # Change actor name @actor.name = @edit_window.name # Play decision SE $game_system.se_play($data_system.decision_se) # Switch to map screen $scene = Scene_Map.new end if Input.trigger?(Input::Key['Space']) @actor.name = @edit_window.name $game_system.se_play($data_system.decision_se) @edit_window.add(" ") end name_input_update end end The error I got was:Script 'Advanced Name Input' line 81: NoMethodError occurred.undefined method `name' for nil:NilClass After testing without the advanced name input script, I saw that the same thing happens with the default Window_NameEdit, but the error is on line 22 I would look into it right now, but I gotta go. If you don't reply by the time I'm back, I'll take a look at it. Thanks :D edit: back...and I don't have a clue what to do. Edited June 3, 2014 by Bob423 Share this post Link to post Share on other sites
Moonpearl 32 Report post Posted June 3, 2014 Hmm, correct me if I'm wrong, but the way your code is written, it's designed to show the name of a specific character (apparently actor #11) rather than the name of, say the party's first member, isn't it? Share this post Link to post Share on other sites
Bob423 52 Report post Posted June 3, 2014 yup. And it's actor 10 (no, 0 is not actor 1, I checked) Share this post Link to post Share on other sites