MZ Saving over an save with js call

Hello There. For my games I use a self made menu thats mostly made of events with a lil more events. Anywho for my save "system" Im using a pretty simple script call to save the game. But this call doesnt support the saving over a save. If there is already a save the call just doesnt do anything. So can someone maybe help me motifi the call so that it CAN save over an already made save in that set save slot?
Schermopname (1243).png
are you certain that the save hasnt been saved? the function allows for overwriting normally if plugins arent involved. the promise returned on a successful save is the number 0, so you would get your error message if you ran it as 0 is falsy but it still should have saved the file
are you certain that the save hasnt been saved? the function allows for overwriting normally if plugins arent involved. the promise returned on a successful save is the number 0, so you would get your error message if you ran it as 0 is falsy but it still should have saved the file
So far I know yea. I save on save 2. do something that should be savable. save again over save 2. close the game. Open the game. Load save 2 and the thing I did before the second save didnt save. Ive tried this with alot of things but it for some reason just doesnt work
I would recommend to put this into a plugin, and call a function something
like:

fuction SavingProgress() {/*your code*/} and call that one.

scriptcalls has a max 11 lines (unless changed in MZ, so opening it later will remove
everything more than 11 lines.

a 1 liner can work too, but making it a function is 1 call and it runs that code.

but its only a feedback 🙂
scriptcalls has a max 11 lines (unless changed in MZ, so opening it later will remove
everything more than 11 lines.
that was changed in MZ to my knowledge. it shouldnt have a limit

So far I know yea. I save on save 2. do something that should be savable. save again over save 2. close the game. Open the game. Load save 2 and the thing I did before the second save didnt save. Ive tried this with alot of things but it for some reason just doesnt work
is that the full script? id like to try it later today
that was changed in MZ to my knowledge. it shouldnt have a limit


is that the full script? id like to try it later today
Yes thats what I use for it yea. I can copy it here so its easier for you to test?
Yes thats what I use for it yea. I can copy it here so its easier for you to test?
Yeah, post the text here and ill check it out when i can
Yeah, post the text here and ill check it out when i can

Okay nice. Here is the save script call I use

try {

// Set saving flag

$gameTemp.saving = true;



// Ensure game state is prepared

$gameSystem.onBeforeSave();



// Introduce a short delay to ensure all processes are stable

setTimeout(() => {

// Perform the save operation

DataManager.saveGame(2).then(function (success) {

if (success) {

console.log("Game saved successfully in slot 2.");

} else {

console.error("Failed to save game.");

}

}).catch(function (error) {

console.error("Error during save operation:", error);

}).finally(function () {

// Clear saving flag

delete $gameTemp.saving;

});

}, 100); // 100ms delay

} catch (error) {

console.error("Unexpected error during save preparation:", error);

}
Here is the save script call I use
So, ive taken it and ran it in a fresh project ant it doesnt seem to have any issues with saving or overwriting files. As mentioned, the failure message plays in the console cause you'd need to see if success === 0 rather than just ifsuccessis truthy, but it still saves and i can exit, reopen the game, and load the save. Are you using any plugins, and if so, have you tried seeing if it works after you disable them?
So, ive taken it and ran it in a fresh project ant it doesnt seem to have any issues with saving or overwriting files. As mentioned, the failure message plays in the console cause you'd need to see if success === 0 rather than just ifsuccessis truthy, but it still saves and i can exit, reopen the game, and load the save. Are you using any plugins, and if so, have you tried seeing if it works after you disable them?
There wasnt an error message ever for me. It just didnt save over. Just nothing. To the question of plugins not that I know of. I dont use any plugins that interact with saves by any means
So, ive taken it and ran it in a fresh project ant it doesnt seem to have any issues with saving or overwriting files. As mentioned, the failure message plays in the console cause you'd need to see if success === 0 rather than just ifsuccessis truthy, but it still saves and i can exit, reopen the game, and load the save. Are you using any plugins, and if so, have you tried seeing if it works after you disable them?
Is there maybe something wrong with the load script call then?
Schermopname (1245).png
Is there maybe something wrong with the load script call then?
im assuming loadSuccess, loadFailure, and afterLoad are meant to be comments? cause without them it should load the save, and with them... it should crash as is.
im assuming loadSuccess, loadFailure, and afterLoad are meant to be comments? cause without them it should load the save, and with them... it should crash as is.
I think so then. I didnt write the call. I found it on a google doc list with alot of those calls on it hehe
Looks like it's the Continue/Load entry from the MV / MZ Script Call List:
Here's a screenshot for quick reference (click to view full size):

scl-continue-load-whead.png
Make sure to read the Notes column! See how loadSuccess, loadFailure, and afterLoad have been replaced with actual code in the example?

This particular script call does have a few extra quirks, though. It can bug out in various situations (e.g. loading a save made on a map with fewer events than are on the current map?), since the core scripts are not designed to permit loading a save during a frame update on the map.


You could try out feature D21 (synchronous save/load plugin commands) of my plugin Cae_Tweaks:
It now has a "Safe Load" parameter: when this is enabled, it performs the actual load on a separate scene, which based on my testing seems to eliminate all problems. All features of Cae_Tweaks are disabled by default, so if you want to try it out then you'll need to scroll down the parameter list and set D21: Save/Load Commands to true.
Looks like it's the Continue/Load entry from the MV / MZ Script Call List:
Here's a screenshot for quick reference (click to view full size):

View attachment 365409

Make sure to read the Notes column! See how loadSuccess, loadFailure, and afterLoad have been replaced with actual code in the example?

This particular script call does have a few extra quirks, though. It can bug out in various situations (e.g. loading a save made on a map with fewer events than are on the current map?), since the core scripts are not designed to permit loading a save during a frame update on the map.


You could try out feature D21 (synchronous save/load plugin commands) of my plugin Cae_Tweaks:
It now has a "Safe Load" parameter: when this is enabled, it performs the actual load on a separate scene, which based on my testing seems to eliminate all problems. All features of Cae_Tweaks are disabled by default, so if you want to try it out then you'll need to scroll down the parameter list and set D21: Save/Load Commands to true.
Oh I see thanks. Ive done some testing and stuff and I dont really know what the problem was but it seems to be solved now. Thanks for the help :3

Original thread: https://forums.rpgmakerweb.com/threads/saving-over-an-save-with-js-call.183447/