code:
# draw character name
actor = $game_party.actors
draw_actor_name(actor, x, y - 72)
I added that code in window_savefile. It works when I'm saving but I got an error when loading. I'm guessing that when I play the game again, the character name isn't loaded yet.
*moves to Script Troubleshooting*
This is what you need to do. Window_SaveFile, look for
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)
@total_sec = @frame_count / Graphics.frame_rate
file.close
end
This is loading everything you need for you. So go down to your refresh method, and you'll see another line that says:
Under that you want to add your code. And instead of using $game_party.actors, use @characters
actor = @characters[0]
draw_actor_name(actor, x, y - 72)
code:
for i in 0...@characters.size
characters_name = @characters
width = self.contents.text_size(characters_name).width
x = 0 * i + width
self.contents.draw_text(x, 5, width, 32, characters_name)
end
I used this code. It worked but it's getting the character's PNG file name.
Oh derp. Sorry, you're right. That's just the array of file names lol. Try this then. Replace Window_SaveFile with that. Or you can just copy the code where I load more variables from the file.
#==============================================================================
# ** 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 = "Save#{@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)
@self_switches = Marshal.load(file)
@screen = Marshal.load(file)
@actors = Marshal.load(file)
@party = 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}"
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 = 300 - @characters.size * 32 + i * 64 - cw / 2
self.contents.blt(x, 68 - ch, bitmap, src_rect)
end
# 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, 8, 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, 40, 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
I made it load actors and party members. So now you can do this.
for i in 0...@characters.size
character_name = @party.actors[i].name
x = 0 * i + width # this line is pointless, it's always going to equal X
self.contents.draw_text(x, 5, width, 32, character_name)
end