Help With Creating A Menu Using Events.

Cole_Carbert

Veteran
Veteran
Joined
Sep 2, 2018
Messages
39
Reaction score
0
First Language
English
Primarily Uses
RMMV
I'm trying to event my title screen, but so far I'm having very little luck. I want to restrict the player to one save file, so I need the title screen to load save file one without the need for the 'Load Save File' screen. I'm also having a lot of trouble getting the game autosave to file 1 without needing to open the 'Save Game Menu'. Can anyone help me? This is really important for setting up the aesthetic of my game.
 

Bex

Veteran
Veteran
Joined
Aug 2, 2013
Messages
1,314
Reaction score
315
First Language
German
Primarily Uses
RMMV
Here the RMMV Scriptcall List.
https://forums.rpgmakerweb.com/index.php?threads/rpg-maker-mv-script-call-list.46456/

There is some code for Load or Safe a File, but i never used it so i dont know how to make it work.
Maybe someone else knows more.

Edit: Do you use Events and Eventcode to Check which Menu Button was pressed?
If the Button for Load is pressed, just exchange the Open Load Screen command with
the correct commands of the scriptcall list.
 

Nightblade50

Developer of "Delta Origins"
Veteran
Joined
Nov 10, 2016
Messages
2,079
Reaction score
4,208
First Language
English, French
Primarily Uses
RMVXA
To force save in file 1, do a script call with this command:
Code:
$gameSystem.onBeforeSave();
if (DataManager.saveGame(1)) {
  StorageManager.cleanBackup(1);
}
To force load file 1, use this script call:
Code:
if (DataManager.loadGame(1)) {
    $gamePlayer.reserveTransfer($gameMap.mapId(), $gamePlayer.x, $gamePlayer.y);
    $gamePlayer.requestMapReload();
    SceneManager.goto(Scene_Map);
}
 

Another Fen

Veteran
Veteran
Joined
Jan 23, 2013
Messages
536
Reaction score
249
First Language
German
Primarily Uses
I might be wrong here, so...

The
$gamePlayer.requestMapReload();
part in the load script is usually done to reset the map if the game was since updated. It resets parallel processes and the position of all events, which you might not want in a normal playthrough.

If you go by the code from the original process from the loading menu ("Scene_Load.prototype.onSavefileOk" in rpg_scenes.js) there is an added version check, so it would look like this:
Code:
if (DataManager.loadGame(1)) {
    if ($gameSystem.versionId() !== $dataSystem.versionId) {
        $gamePlayer.reserveTransfer($gameMap.mapId(), $gamePlayer.x, $gamePlayer.y);
        $gamePlayer.requestMapReload();
    }
    SceneManager.goto(Scene_Map);
}

Maybe more importantly, loading/saving is usually not supposed to be done in the middle of an update cycle (when event commands would be run) and I'd suggest using a small plugin for this instead of using these commands directly in an event script command.
Saving the game in a script command might skip a part of the update process and events may be slightly out of sync when you reload (if you used a parallel process). Also, since the script command was not finished at the time of saving, it is probably going to get repeated.

Loading the game in a script command will cause the game to finish updating the old events and parallel processes, but all references to switches etc. will use the freshly loaded data instead.
For example, if you have a parallel process running that gives the party an item while you load the savestate, it is possible that the newly loaded inventory is changed instead. It could also trip up some third party plugins that work on the map or events.
(Also, if you use the version check above, the player could walk onto impassable terrain if they start moving the frame the savefile is loaded.)

I'm not sure if this is the best place to do it, but my suggestion would be to move the script command to the end of the map screens update process and use a switch or something to trigger it:
(I'm not sure if this is the best place to put it, but it should work. For sake of simplicity, a switch is used to trigger the script commands, but you could also add a more meaningful flag):

Code:
(function() {

// The main update function is modified and saving/loading is added to the end of it:
var oldSceneMapUpdateMain = Scene_Map.prototype.updateMain;
Scene_Map.prototype.updateMain = function() {
    oldSceneMapUpdateMain.call(this);
    // Check if Save is requested (Indicated by Switch 10 here):
    if (this.isActive() && $gameSwitches.value(10) === true) {
        $gameSwitches.setValue(10, false);
        // Execute the Script Command from above:
        $gameSystem.onBeforeSave();
        if (DataManager.saveGame(1)) {
            StorageManager.cleanBackup(1);
        }
    }
    // Check if Load is requested (Indicated by Switch 11 here):
    if (this.isActive() && $gameSwitches.value(11) === true) {
        $gameSwitches.setValue(11, false);
        // Execute the Script Command from above:
        if (DataManager.loadGame(1)) {
            if ($gameSystem.versionId() !== $dataSystem.versionId) {
                $gamePlayer.reserveTransfer($gameMap.mapId(), $gamePlayer.x, $gamePlayer.y);
                $gamePlayer.requestMapReload();
            }
            SceneManager.goto(Scene_Map);
        }
    }
}

})();

Edit: Welp, that exploded a bit, may have to edit this later. Hope I'm not writing complete reddish here...
 
Last edited:
  • Like
Reactions: Bex

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Trauma, drama, llamas--sadly the only one of those things I'm not experiencing RN is the camelids.
Do you ever just write or say nonsense? String together words to make a sentence that sounds pretty but is meaningless?
Writing down my ideas for my next game during break times at work XD I need to finish my current one very soon.

Forum statistics

Threads
93,661
Messages
914,368
Members
123,246
Latest member
Aspaqi
Top