Help With Creating A Menu Using Events.

Discussion in 'RPG Maker MV' started by Cole_Carbert, Oct 1, 2019.

    Tags:
  1. Cole_Carbert

    Cole_Carbert Veteran Veteran

    Messages:
    37
    Likes Received:
    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.
     
    #1
  2. Bex

    Bex Veteran Veteran

    Messages:
    1,265
    Likes Received:
    299
    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.
     
    #2
  3. Nightblade50

    Nightblade50 Developer of "Delta Origins" Veteran

    Messages:
    2,062
    Likes Received:
    4,175
    Location:
    USA
    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);
    }
     
    #3
    Black Pagan and Bex like this.
  4. Another Fen

    Another Fen Veteran Veteran

    Messages:
    531
    Likes Received:
    244
    First Language:
    German
    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: Oct 2, 2019
    #4
    Bex likes this.

Share This Page