I'm still pretty bad at scripting, but this should be an easy enough one for me to do. Replacing the standard sprite bitmap on a save file with one particular actor's name (which will be used as chapter names rather than a character name, easier to change that way). Unfortunately, no matter what I do I cannot get it to work right. I can get rid of the sprite easily, and can put in the text exactly as I want it to be if I were to type the text in directly, but it simply will not take the actor name itself no matter what I do. I wanted to be able to get it on my own, but it clearly there's something I'm missing. Anyone able to give me a pointer?
To get the name of an actor with database ID:
To get name from Party ID:
party.actors[<id>].name # You have to load the party data from savefile first, or save the name into the beginning of save file
Can you post your code, so that we can see what you're doing wrong...?
Already tried the first one, though I'll take a stab at the second one.
My game isn't on this computer unfortunately, so I can't post the code. Pretty much I just removed the sprite section, and after the time stamps I added another few lines that puts text right in the middle of the file window. That part works fine, it's just telling it what to put in as the text is where I can't get it to work.
Odd. The first one should be working unless you're screwing up the syntax or something :/
It should be something like
self.contents.draw_text(<x here>, <y here>, <width here, should be as much as you can get>, <height here, as much as you can get>, $game_actors[<id>].name)
I already tried that almost exactly (added it to be centered rather than left justified), and it had an error. I think nil class something, though I'll have to double check yet again. It's just the $game_actors[_].name that isn't registering.
Quote from: Zylos on June 29, 2009, 01:21:16 pm
I already tried that almost exactly (added it to be centered rather than left justified), and it had an error. I think nil class something, though I'll have to double check yet again. It's just the $game_actors[_].name that isn't registering.
Remember not to try 0. That won't work.
the problem is when he goes to the load screen I bet he gets the error. $game_actors hasnt been called yet. Its only called when a new game is called which causes problems. Instead of using $game_actors use $data_actors then to change the actors name use this
$data_actors[x].name = ""
Quote from: game_guy on June 29, 2009, 01:51:05 pm
the problem is when he goes to the load screen I bet he gets the error. $game_actors hasnt been called yet. Its only called when a new game is called which causes problems. Instead of using $game_actors use $data_actors then to change the actors name use this
$data_actors[x].name = ""
CRAP, I had $game_actors confused with that >_<
The method works, but not the way I wish it. It will print the same actor name on all existing files regardless of what the actor's name is at the time it is saved. If I changed the name in the course of the game, it will still be the default actor name if I go to the load screen from the title screen. Example, if the actor's name is Bob and I save one file with him named Joe and another with him named Adam, they will all be listed as Adam (since it is the current name) unless I'm loading from the beginning, in which case they will all be listed as Bob. ._.
Best bet is to actually use a game system thin for the chapter. Here I'll make someting for you real fast.
Here
# All you do is use this to change the chapter
# $game_system.chapter = "Chapter X"
class Game_System
attr_accessor :chapter
alias add_chapter_later initialize
def initialize
@chapter = "Chapter 1"
add_chapter_later
end
end
class Window_SaveFile < Window_Base
def refresh
self.contents.clear
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 @file_exist
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
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)
self.contents.font.color = normal_color
time_string = @time_stamp.strftime("%Y/%m/%d %H:%M")
self.contents.draw_text(4, 40, 600, 32, @game_system.chapter, 2)
end
end
end
Edit:
So wait you want it to display several chapter names?
I dont really understand your request
Tsk tsk tsk... Can't believe you double posted... this is your 2nd time!!! D:::::
~Aqua
That did the trick, though I'm puzzled now because I wrote near the same exact thing before without any success. Well, at any rate, this works for me. Just a bit of editting to my needs and it'll work perfect. Thank you.
Alternatively, you can add
Marshal.dump(<file name>, $game_actors[1].name)
in Scene_Save right above the rest of the Marshall code, and tune just load the string from each save file to get the name. Same thing, really, but saving all of Game_System is overkill (unless you're aiming for making a stand-alone script, but I take it this is for your own game only :P)
I use $game_system only for system settings. Party related variables go to $game_party, actor related variables go to each Game_Actor instance.