Save file class

Spoiler
$game_actors[1].class

I'm using More Informative Saves script. I need a script call that, on the save file, displays the actor's class. Actor can change class on the fly, so I didn't use a class ID. I tried spoiler, but it only showed the formula.

I've moved this thread to RGSSx Script Support. Thank you.



RGSSx Scripts is for completed scripts which you have made yourself.
Moved to: RGSSx Script Support

RGSSx Scripts is for completed scripts which you have made yourself.

Thanks, I sometimes get subforums mixed up. Also, this is the script I'm talking about. The part I'm changing is:
Spoiler
# Variables to show on the save/load screen.
# Format:
# ["name", "value", x position or align, line number],
#-----------------------------------------------------------------------------
#-"name" can be called whatever you want, as long as there are no spaces.
# I'd recommend naming it something useful so you know what it is, and to
# put "_s" (for save) at the end so there are no conflicts with other things.
#-"value" is any bit of game data that you want to show up on the save.
#-----------------------------------------------------------------------------
# Put a # in front of the ones you don't want to show
# **Don't forget the comma after each []!**

["playtime_s", "$game_system.playtime_s", 2, 0],
["location_s", "$game_map.display_name", 2, 1],
#["gamevariable1", "$game_variables[1]", 2, 2],
What do you mean by "Actors can change class on the fly, so I didn't use a class id"? What are you using to define the class, if not a class id?

The actors already get saved into the save header, under header[:characters] so you don't even need to save the class - you can access it from there. You would just need to modify this method:

Code:
  def draw_party_characters(x, y, spacing)
    header = DataManager.load_header(@file_index)
    return unless header
    header[:characters].each_with_index do |data, i|
      draw_character(data[0], data[1], x + i * (32 + spacing), y)
    end
  end

and add a line after draw_character to draw_text with $data_classes[data.class_id].name as the string to display, working out what the other arguments need to be based on where you want it to appear.
What do you mean by "Actors can change class on the fly, so I didn't use a class id"? What are you using to define the class, if not a class id?

Thank you!

The actor chooses a class at the start of the game, and can change the class whenever, so I thought adding an id would tie the class displayed to the class identified rather than to the class that the actor currently has. I've tried class_change in the save menu, but the neither the class nor the formula showed up on the save file.

The actors already get saved into the save header, under header[:characters] so you don't even need to save the class - you can access it from there. You would just need to modify this method:

Code:
  def draw_party_characters(x, y, spacing)
    header = DataManager.load_header(@file_index)
    return unless header
    header[:characters].each_with_index do |data, i|
      draw_character(data[0], data[1], x + i * (32 + spacing), y)
    end
  end

and add a line after draw_character to draw_text with $data_classes[data.class_id].name as the string to display, working out what the other arguments need to be based on where you want it to appear.

I did this at lines 191-198:

Spoiler
def draw_party_characters(x, y, spacing)
header = DataManager.load_header(@file_index)
return unless header
header[:characters].each_with_index do |data, i|
draw_character(data[0], data[1], x + i * (32 + spacing), y)
draw_text[$data_classes[data.class_1].soldier]
end
end

However, while the class is supposed to appear under the map's name in the save file, nothing appears below it.

Spoiler
Capture.PNG
Whenever the actor changes classes, their class id changes. This is how the game keeps track of what their current class is.

That is not how you write a draw_text command. And that is not how you refer to a class. That is not what I put at all. I did say that you would need to work out the arguments. Find an existing draw_text command (or look up the one in Window_Base) and put in the right values.

I would actually have expected your code to throw an error.
Whenever the actor changes classes, their class id changes. This is how the game keeps track of what their current class is.

That is not how you write a draw_text command. And that is not how you refer to a class. That is not what I put at all. I did say that you would need to work out the arguments. Find an existing draw_text command (or look up the one in Window_Base) and put in the right values.

I would actually have expected your code to throw an error.

Thanks! I'll check it out. Is this the script I use?

Code:
$data_classes[data.class_id].name
That is what you use in the show_text command, as the "text" that's going to be printed. It will look like this:

Code:
show_text(some arguments here in some order, including $data_classes[data.class_id].name, as well as some other stuff)

The "other stuff" will include the x and y positions, and maybe a line height and width, and there might also be an alpha/opacity/enabled argument that you can just ignore.
That is what you use in the show_text command, as the "text" that's going to be printed. It will look like this:

Code:
show_text(some arguments here in some order, including $data_classes[data.class_id].name, as well as some other stuff)

The "other stuff" will include the x and y positions, and maybe a line height and width, and there might also be an alpha/opacity/enabled argument that you can just ignore.

Thank you, that makes much more sense than what I've read about draw_text. I think the thread can be closed now 🙂
To get a thread closed, you need to report your first post and ask for it to be closed. That'll notify the mods straight away, rather than waiting/hoping for them to see your post. However, you might want to wait until you actually get it working, otherwise you'll have to ask for it to be reopened.

Also, you don't need to quote posts when you're posting immediately after them, especially when you're not actually responding to anything in particular in the post.

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/save-file-class.75223/