Renaming an actor's class

First off, hope I'm in the right topic.

I'm trying to write a scriplet that allows the player to rename a given class to whatever the want. I've got it work, but it won't save. I rename the class and it shows as the new name everywhere in the game. I can save the file, but when I load it the class's name reverts back to it's original name. I thought it was because I wrote it into the wrong area in scripts (meaning one that doesn't save in the save file), so I put it in Game_System.. but still no luck.

Any help would be great 😉

Spoiler
Code:
#==============================================================================# ■ Game_System  #==============================================================================# Script call in event:#    $game_system.rename_class(1)#==============================================================================class Game_System  ActorID_for_Renaming = 8    # Actor ID for renaming purpose  Name_Length          = 12   # Character length for class name  #--------------------------------------------------------------------------  # new method: rename_class  #--------------------------------------------------------------------------  def rename_class(class_id)    name_length  = 12                                # Max length for name    class_name   = $data_classes[class_id].name      # Get current class name    # Change actor place holder name to class name    $game_actors[ActorID_for_Renaming].name = class_name    # Call Name Input scene    SceneManager.call(Scene_Name)    SceneManager.scene.prepare(ActorID_for_Renaming, name_length)    # Wait for the Naming process to stop    Fiber.yield    # Change the class name to the input name    $data_classes[class_id].name = $game_actors[ActorID_for_Renaming].name  endend 
Nope - wrong forum. Since this is a Script question, it needs to go into the RGSSx Script Support forum (and I'll move it there now).

Anything beginning with $data is fixed data loaded from the database, and is not included with the save file. This is why your changes aren't sticking. Nor do you want them to, because $data_classes is used by ALL save files. I would also not recommend just adding $data_classes to the list to be included with the save file.

You'll notice your $data_actor information is first put into the $game_actors array, which is why you can change an actor's name or sprite and have it "stick" when the game is saved and loaded.

Here's what I'd do:

Spoiler
class Game_Actor < Game_Battler attr_accessor :class_name alias shaz_class_name_setup setup def setup(actor_id) shaz_class_name_setup(actor_id) @class_name = $data_classes[class_id].name end alias shaz_class_name_change_class change_class def change_class(class_id, keep_exp = false) shaz_class_name_change_class(class_id, keep_exp = false) @class_name = $data_classes[class_id].name endendclass Window_Base < Window def draw_actor_class(actor, x, y, width = 112) change_color(normal_color) draw_text(x, y, width, line_height, actor.class_name) endend
Then in your own script, instead of using $data_classes[class_id].name, use $game_actors[id].class_name - also if there are other windows where the class name is shown (I've already modded Window_Base, and that might actually be enough) you'll need to change it to actor.class_name instead of $data_classes[id].class_name

I have not tested this. Let me know if it generates any errors.
That did save it. And very useful info.  I forgot it's meant for a class/subclass script. But I think you set me on the right track 🙂

Thanks and this can be closed out.
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/renaming-an-actors-class.18116/