Auto-Save? Script Call to force save?

Hi there, been looking on forum's for a way to auto save via script call, I have found some call's but none seem to work for me 🙁

$gameSystem.onBeforeSave(); DataManager.saveGame( index ) ' index being the number to save file on ' does not work
anyone know how I can do this?
p.s don't know if this is right place for this 😛 haha.
It's not the right forum, but which one you want will depend on if you are using ACE or MV. Which engine is this for?
I'm curious about this too...for MV. One to force a save to the nearest blank save slot?
Apologies I forgot to say it's for MV. Is there a script call for it that works ? Thanks for replying.

I've moved this thread to JavaScript Support. Thank you.

Just made a test and DataManager.saveGameWithoutRescue(savefileID) seems to work, I think I replied to you in another thread yesterday, right? Sorry about the wrong savegame orz
I wouldn't just use that function, because it lacks the call to StorageManager.backup that the standard save command has. If something goes wrong with the save and all you did was call saveGameWithoutRescue, you'll corrupt your file. The code that runs when you choose a save file is

Code:
try {
        StorageManager.backup(savefileId);
        return this.saveGameWithoutRescue(savefileId);
    } catch (e) {
        console.error(e);
        try {
            StorageManager.remove(savefileId);
            StorageManager.restoreBackup(savefileId);
        } catch (e2) {
        }
        return false;
    }

So basically do that as a script call but instead of the parameter savefileId put the actual number of the slot you want to put the forced save file in.
Hey thanks @Shugo
@Trihan , I did see on some forums there was a chance it could corrupt the file, this looks like it will work and you know your stuff 😛.. do I replace savefile id with the slot I wish it to a save on? Thanks
@SoSick. Yes you do, that's why I told you to replace savefileId with the slot you wish to save it on. 😉
Omg lol trying to watch tv and be on here. I clearly can't multi task. xD Thanks again.
(Deleted)
Hello, I would need an update on this method (RPGMAKER MV 1.6.1)
I'm also trying to have an auto-save script inside my game, but all the suggested solutions here don't work (or don't work anymore)

@Trihan solution returns an error
The code that runs when you choose a save file is

Code:
try {
        StorageManager.backup(savefileId);
        return this.saveGameWithoutRescue(savefileId);
    } catch (e) {
        console.error(e);
        try {
            StorageManager.remove(savefileId);
            StorageManager.restoreBackup(savefileId);
        } catch (e2) {
        }
        return false;
    }
So basically do that as a script call but instead of the parameter savefileId put the actual number of the slot you want to put the forced save file in.
horror.png


and @Shugo method
Code:
DataManager.saveGameWithoutRescue(savefileID)
completed as
Code:
DataManager.saveGameWithoutRescue( DataManager.lastAccessedSavefileId() )
indeed corrupts the game save
the new save is created, even if the autosave is called on a new game without previous saves, it neatly creates the new save into an empty slot, but the save created this way can't be loaded later on, meaning it's unusable

(the unusable save may also be caused by various game plugins, which add features which require addons into the game save, addons which likely aren't carried over with this method)

So which is a currently working method to auto-save a game, while skipping the manual save slot selection screen?
Found a working code for auto-save while looking more for it
Code:
$gameSystem.onBeforeSave();
DataManager.saveGame( DataManager.lastAccessedSavefileId() );
This code seems to work properly, and the created save can be loaded fine

Other references

Original thread: https://forums.rpgmakerweb.com/threads/auto-save-script-call-to-force-save.75236/