Milennin

"With a bang and a boom!"
Veteran
Joined
Feb 7, 2013
Messages
3,017
Reaction score
2,277
First Language
English
Primarily Uses
RMMV
I'm looking for a plugin with the following feature:
-An option to save/load game to/from savestate1 using a plugin command.

Thanks to anyone willing to make this.
 

Aloe Guvner

Walrus
Veteran
Joined
Sep 28, 2017
Messages
1,628
Reaction score
1,152
First Language
English
Primarily Uses
RMMV
I wrote code for autosave / autoload here in the JS snippets thread, so that can be converted to a plugin command like this:

Code:
(function() {
    const Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;
    Game_Interpreter.prototype.pluginCommand = function (command, args) {
        Game_Interpreter_pluginCommand.call(this, command, args);
        if (command.toLowerCase() === 'autosave') {
            let saveId = 1;
            if (args && args[0]) {
                saveId = parseInt(args[0]);
            }
            $gameSystem.onBeforeSave();
            if(DataManager.saveGame(saveId)) {
                StorageManager.cleanBackup(saveId);
            }
        }
        if (command.toLowerCase() === 'autoload') {
            let saveId = 1;
            if (args && args[0]) {
                saveId = parseInt(args[0]);
            }
            if(DataManager.loadGame(saveId)) {
                SoundManager.playLoad();
                SceneManager._scene.fadeOutAll();
                $gamePlayer.reserveTransfer($gameMap.mapId(), $gamePlayer.x, $gamePlayer.y);
                $gamePlayer.requestMapReload();
                SceneManager.goto(Scene_Map);
                $gameSystem.onAfterLoad();
            }
        }
    }
})();

You can now use a plugin command in the following formats (note it is not case sensitive, i.e. 'AuToSaVe' is the same as 'autosave' or 'Autosave')
Code:
autosave     // saves to slot 1
autosave 8  // save to slot 8
autoload    // loads from slot 1
autoload 8 // loads from slot 8
 

Milennin

"With a bang and a boom!"
Veteran
Joined
Feb 7, 2013
Messages
3,017
Reaction score
2,277
First Language
English
Primarily Uses
RMMV
@Aloe Guvner Awesome, thanks. I'm at work right now, but will try it as soon as I get home.
 

Milennin

"With a bang and a boom!"
Veteran
Joined
Feb 7, 2013
Messages
3,017
Reaction score
2,277
First Language
English
Primarily Uses
RMMV
@Aloe Guvner I've been getting this error: "Cannot read property 'pages' of undefined" upon autoloading a save state. After some testing different scenarios, I'm thinking it only occurs when autosaving and then autoloading within the same session, because when I autoload that same save state after a reset or restart of the game, it works just fine.
 

Aloe Guvner

Walrus
Veteran
Joined
Sep 28, 2017
Messages
1,628
Reaction score
1,152
First Language
English
Primarily Uses
RMMV
@Milennin Works fine when I test it on a blank project with no other plugins enabled.

So you probably know what my next questions are:
  • Can you post a screenshot of the full error message from the Console (press F8 during playtest to open the console)
  • Does this error occur on a blank project with no other plugins installed?
    • If no, turn on the other plugins one-by-one until it crashes, which will identify the incompatible plugin
 

Milennin

"With a bang and a boom!"
Veteran
Joined
Feb 7, 2013
Messages
3,017
Reaction score
2,277
First Language
English
Primarily Uses
RMMV
@Aloe Guvner This is a screenshot with all plugins turned off:
Fvgkcu0.png

I can try in a blank project later, but short on time right now.
 

Aloe Guvner

Walrus
Veteran
Joined
Sep 28, 2017
Messages
1,628
Reaction score
1,152
First Language
English
Primarily Uses
RMMV
How about a blank map with only 2 events, one for autosave and one for autoload set to a trigger of Action Button. Does it work in this scenario?
 

Milennin

"With a bang and a boom!"
Veteran
Joined
Feb 7, 2013
Messages
3,017
Reaction score
2,277
First Language
English
Primarily Uses
RMMV
How about a blank map with only 2 events, one for autosave and one for autoload set to a trigger of Action Button. Does it work in this scenario?
Yes.

It also works in my existing project in some scenarios, but can't find out when it breaks, after doing more testing. Like, I put the load command at the top of an event, it works. I put it below a few commands, it breaks. But then I put it back at the top, and it still breaks. I load the save once, it works. I load it again from the same event, it breaks.
I digged around and found a script call to auto load the game, which seems to give more consistent results. It only really seems to break if I transfer the player right as the game loads. Put in a wait 1 frame between it, and it works fine. The script call error, when it pops up, is pretty similar, except it says null, instead of undefined at the end.
 

Aloe Guvner

Walrus
Veteran
Joined
Sep 28, 2017
Messages
1,628
Reaction score
1,152
First Language
English
Primarily Uses
RMMV
Probably then due to some way how it initializes the map (and thus, initializes all the events on the map). The autosave/autoload script I proposed has the standard MV functions almost exactly how they are used in the save/title scenes. But loading from the title scene is probably simpler than loading directly from the map scene.

I'm not surprised actually that it crashes when trying to use autoload in the middle of an event. When an event is running, it has all the commands queued up in a list, and it works through that list. When trying to reload a map, that list might still be present in memory. The standard MV functions for load only happen normally from the title screen, so probably it never clears that queued list from the memory.

If you have a map where it consistently crashes, feel free to PM me the MapXXX.json file (from your data folder) of that map. Don't send any of the graphics, I'll just replace it with the RTP graphics. I'll run the debugger and try to see what's causing it.
 

OktoberLove

Veteran
Veteran
Joined
Feb 11, 2019
Messages
61
Reaction score
24
First Language
English
Primarily Uses
RMMV
Did you guys ever find out what was causing this?
 

Milennin

"With a bang and a boom!"
Veteran
Joined
Feb 7, 2013
Messages
3,017
Reaction score
2,277
First Language
English
Primarily Uses
RMMV
Did you guys ever find out what was causing this?
Not exactly. Putting in a 1 frame wait seemed to make it work in more cases, but it still messed up in some scenarios. Getting to an auto-load event that worked was good enough, because when it works, it works consistently. When it fails, it fails consistently.
 

Latest Threads

Latest Posts

Latest Profile Posts

I just finished Variables I lesson! Urrah! I'll be publishing it soon. :smile:
Hopefully brighten your Monday.
SwordSkill wrote on alice_gristle's profile.
Hey, wanna give my project a try? I promise it will be easy.
Seeker Clones.png
Work on the Decepticon Seeker sprites is taking longer than I anticipated. I have five down: Starscream, Thundercracker, Skywarp, Acid Storm and Nova Storm. Three left to go: Ion Storm, Sunstorm (needs rework), and Slipstream. After completing their walking sprites, should I wait to post them after I've done a transformation sequence?

Forum statistics

Threads
118,672
Messages
1,117,778
Members
155,787
Latest member
Klaus_LP1
Top