MZ 'Save data is too big' console warning

111111111111111.png

I wrote code to add switch information to the save file. If I save a file after that, I can't save it with a console warning 'Save data is too big'.

22222222222222222.png

How do I save a switch or variable to save file without console warning? This is quite important. Because I'm creating a feature that changes the information displayed on the save screen based on the value of the saved switch.
The correct syntax is $gameSwitches.value(641), not $gameSwitches(641).

Also, you could patch the method instead of overriding it, e.g.
Spoiler: plugin code snippet
JavaScript:
(() => {
  const alias = DataManager.makeSavefileInfo;
  DataManager.makeSavefileInfo = function() {
    const info = alias.apply(this, arguments);
    info.lv = $gameActors.actor(1).param(0);
    info.switch01 = $gameSwitches.value(641);
    return info;
  };
})();
The correct syntax is $gameSwitches.value(641), not $gameSwitches(641).

Also, you could patch the method instead of overriding it, e.g.
Spoiler: plugin code snippet
JavaScript:
(() => {
  const alias = DataManager.makeSavefileInfo;
  DataManager.makeSavefileInfo = function() {
    const info = alias.apply(this, arguments);
    info.lv = $gameActors.actor(1).param(0);
    info.switch01 = $gameSwitches.value(641);
    return info;
  };
})();
Thank you very much! Thanks for suggesting a better way.
You're welcome, hopefully it works now~

Original thread: https://forums.rpgmakerweb.com/threads/save-data-is-too-big-console-warning.166903/