MZ Requesting assistance, saving and loading custom data

Hi, I find myself stuck with a problem I've been having for the past week. yeah a week... maybe more idk at this point however I do know what the problem is. Attached is a horribly coded example of my thing where it does a thing namely copies data from an object and loads it when it is needed. The code runs and should be more or less straightforward. its a menu for save/load only for save rn as this is where my problems reside.

now, the problem is that I need to add a new var to this.

JavaScript:
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.customData = 777; // <<---- like this
    return info;
};

that's been accomplished, now when I try to load the data which needs to be loaded before actually opening a file, the data returns the original, in this case its 777 even after loading a file editing the data and saving it before restarting the game the data still returns 777. personally I think the idea is sound I have a funny feeling that the problem lies...lays.... with how I try to pull the data. For the most part I've been accessing the data by....
JavaScript:
DataManager.makeSavefileInfo().customData

this hasn't worked out well for me so far. anyway any and all help, info is greatly appreciated. (my method of coding is horrid i know) thanks for your helps. :blush:
with how I try to pull the data. For the most part I've been accessing the data by....
Accessing the data should be
JavaScript:
DataManager.savefileInfo(saveIndex)
Your code is for data generation.
o...ooooh
awesome. ill try that right now.

Update.
returns an empty array.

This thing here is all I'm getting [object object] that's all and I'm assuming its supposed to contain something. however at the time I'm calling it it returns nothing.

Update.

Thought maybe my implementation was wrong, spent hours making sure it wasn't. Apparently there just there just doesn't seem to be a way to load custom data before loading a file . nobody seems to know how at least. Ill continue trying tho and ill find a way no matter how long it takes. @TheoAllen thanks for your assistance.
Ok so the it turns out saving custom data
Accessing the data should be
JavaScript:
DataManager.savefileInfo(saveIndex)
Your code is for data generation.
So yeah idk why it wasn't working but I finally got it to work. But the data is both read and saved using the same snippet you gave me, also its important to note that the data is saved to the file you indicate regardless of which file you use to "save". an example of this would be-

JavaScript:
DataManager.savefileInfo(index)

Say you have 15 save file slots but when saving the data you save using the 3rd slot and with the above code you used, say 8 in the place of index. The data will be allocated to the 8th instance of the save data rather than the 3rd. So in conclusion it is entirely possible to save(or allocate) data to all save instances while saving once in any one slot. Slightly complicated but easy enough once you understand how the game engine saves data.

If anyone needs more info about this id be happy to give a more detailed explanation. So feel free to dm me. oh can a mod pls close this its been solved after all.
easier way to create custom data...
place it inside Game_System...

since Game_System is saved inside savefiles thus you don't need to alter anything in DataManager.

hope this help...
@estriole hi thanks for your reply , but um care to elaborate?
@estriole hi thanks for your reply , but um care to elaborate?
you can define a variable inside Game_System to store your custom data
example in your case the default starting value of the custom data is 777:
Code:
Game_System.prototype.myCustomData = function() {
   if (!this._myCustomData) this._myCustomData = 777;
   return this._myCustomData;
};
Game_System.prototype.setMyCustomData = function(value) {
  this._myCustomData = value;
};
the first function:
so you can use $gameSystem.myCustomData() anywhere to grab the custom data value...
and if it's not defined yet (null)... it will use the default value you set (777). you can change 777 to any starting value you want... or you can also change it to plugin parameter instead so user can customize it...

the second function:
this is for setting the value of the custom data... so you can change it anytime
using $gameSystem.setMyCustomData(your value here)

and since the custom data stored inside Game_System (this._myCustomData variable)
it will be saved to savefile... and no need to alter any DataManager 😀.

hope this help.
ah! @estriole thank you 😢 thank you soo much ive been having a problem and without even trying your code i can tell that itll fix it i wanna hug you thank you again.

Original thread: https://forums.rpgmakerweb.com/threads/requesting-assistance-saving-and-loading-custom-data.133010/