MZ Script For Using Actor Name As Save Name

I hope this is in the right place. I am looking for a script that will use the Actor Name as the Save File name. I found a thread that was for MV, but when I tried to use it for MZ, it didn't seem to work. But I might have done something wrong when I tried to save the script as a plugin and use it in MZ.

Here is the thread that I found.


The problem I am trying to solve is that multiple players could play the game and have access to all the Save files. If they can't easily tell them apart, they could Save over a different player's Save file.

This is for my Sudoku game. This is what I was planning.
  • The game would only have one Actor with the default name of Player.
  • The player would be able to pick their own name, which will change the name of the Actor.
  • The Save files would be named with the name that the player chose.
  • This way, if a different player plays the game and starts a new game, they can input a name, change the name of the only Actor, and be able to tell the Saves apart. Because each player can see all the Saves for any player.
I figured one easy way to help keep one player from saving over another player's Save was to name them.

I tried a plugin that lets the player rename their Save, but it also does a bunch of other things that I don't need and displays things I don't want displayed.

It would be awesome if there was a way to make it so only the Saves with the current player's name were visible. I was wondering if a global switch could be used for something like that.

Anyway, for now, I am just trying to see if there is a script that I can use to differentiate Saves by the name the player decides to use.

I wasn't planning on having the player choose a name, but it was one way I could think of that might allow telling the Save apart.

I guess another option would be if there was just a simple way to let the player name the Save anything they want.

Again, I did try a plugin, but I would need to see if that plugin could be slightly modified since it shows the Actor Level in the Save description and the game won't technically have actor levels. In fact, I wouldn't even have an actor in the game if there is a better way to do this.

If anyone has a better solution, please feel free to make suggestions.

Thanks!
try this as a plugin and load it near the top of the list
Spoiler
Code:
Window_SavefileList.prototype.drawTitle = function(savefileId, x, y) {
    if (savefileId === 0) {
        this.drawText(TextManager.autosave, x, y, 180);
    } else if (DataManager.savefileInfo(savefileId) && DataManager.savefileInfo(savefileId).fileName)
        this.drawText(DataManager.savefileInfo(savefileId).fileName, x, y, 180);
    else {
        this.drawText(TextManager.file + " " + savefileId, x, y, 180);
    }
};

DataManager.makeSavefileInfo = function() {
    const info = {};
    info.title = $dataSystem.gameTitle;
    info.characters = $gameParty.charactersForSavefile();
    info.faces = $gameParty.facesForSavefile();
    info.playtime = $gameSystem.playtimeText();
    info.timestamp = Date.now();
    info.fileName = $gameActors.actor(1).name();
    return info;
};
that should make it so that when the game is saved, the file's name is set to the name of actor 1, which in your case would have already been changed to the player's. sounds good?
@Robro33 Thank you very much! I just tested this quickly and it seems to work perfectly in my test project.

I credited you as the author of the script in the plugin description and I will make sure to credit you in the game.

This just shows me how far I am away from being able to create scripts like this. But I understand more of this as time goes on. But I really need to learn how windows work.

The willingness of people to share their scripting knowledge never ceases to amaze me. I just hope that someday I will be able to return the favor for someone else.

Thanks again!

Original thread: https://forums.rpgmakerweb.com/threads/script-for-using-actor-name-as-save-name.169635/