AutoSave+ (Also for weather, day/night, skillgrid etc)

● ARCHIVED · READ-ONLY
Started by JohnDoeGames 8 posts View original ↗
  1. ========================================
    ABOUT THIS PLUGIN - JDN_AutoSavePlus.js
    ========================================

    This plugin:
    Runs common event of your choice
    - when you switch maps
    - when you lvl up

    Saves or loads the game at a plugin command

    This is useful for:
    - Autosave
    - Weather
    - Day/Night time.
    - Skill grid
    - More...

    example of how to make a weather system with this plugin
    31239472_10209877279363689_8630957714429706240_o.jpg

    Terms Of Use
    ========================================
    TERMS OF USE
    ========================================

    Free to use for commercial, or non commercial projects,
    Credits to: JohnDoeNews
    If you put a link to your credits, please use this link, no matter
    where you found this plugin: http://games.johndoenews.nl

    This plugin may be shared for free, but the tems of use must
    stay the same.

    Plugin Commands
    ========================================
    PLUGIN COMMANDS
    ========================================


    JDNForceLoad
    - This opens the load scene, if a saved game is present, or start
    a new game if no game is saved.

    JDNForceSave
    - This will force a silent save in slot 1

    Devlog
    ========================================
    DEVLOG
    ========================================

    1.1.0 Added params with help of Aloe Guvner
    26 April 2018

    1.0.1 Added common event on lvl up.
    22 April 2018

    1.0.0 Finished!
    19 April 2018

    ========================================
    DOWNLOAD THE PLUGIN ON MY WEBSITE!!
    ========================================

    Link To My Website



    ========================================
    Preview
    =======================================

    The preview of my current project, is in fact made with
    this plugin, and shows a perfect example of how
    to make a weather and a day/night system with this
    plugin: (Just walk around map to map and see the weather
    change slowely)
    Link my project on Itch.io
  2. I want to make parameters, so the user can choose the common event triggered by the plugin.
    Unfortunately I have not been successful so far.

    If anyone who knows JS and took a look at the file, can tell me how to do this, I would be most thankful, and put you in the devlog.
  3. You can use this for reference on all parameter types available:
    https://forums.rpgmakerweb.com/inde...w-plugin-manager-in-rpg-maker-mv-1-5-0.79764/

    Video tutorial on how to make plugin parameters:
    Spoiler
    (basic parameters)
    (new, advanced parameters)


    For your plugin, in the header add:
    Code:
    @param saveSlot
    @text Save Slot
    @type number
    @desc The save slot number that is used in the autosave.
    @default 1

    I see that you included the first 2 methods of your plugin within separate IIFE and the 3rd method is not within an IIFE. You should wrap the whole thing in a single IIFE for better variable scoping and protection.

    So at the top but inside your IIFE:
    Code:
    var params = PluginManager.parameters("Your Plugin Name");
    var saveSlot = Number(params["saveSlot"]);

    Then you can change the line later to:
    Code:
    DataManager.saveGame(saveSlot);

    No credit/dev log required.
  4. Aloe Guvner said:
    ...
    Ha, those are the tutorials I used to make this plugin :p Haha.

    I am quite new to plugins, are java script all together. I am going to try and make it all into one IIFE (function?) and see if I can make it run.

    Would you mind if I credited you for it? It's like saying thank you. :p
  5. If you want to, sure, but not required.

    Yeah an IIFE is an Immediately Invoked Function Expression. The link I posted does a better job explaining, but it's the part that looks like this:
    Code:
    (function() {
       //put all of your stuff here
    })();
    Basically any new variable declared inside there is only local to that function. So you can declare any new variables you want, and it is always safe and won't mess with other plugins.

    That's why it is safe to declare a new variable like this:
    Code:
    var params = PluginManager.parameters("Your plugin name");
    Even though "params" is probably a popular choice for a variable name. Because of the IIFE, it is locally scoped and it doesn't overwrite anybody else's "params".
  6. I tried the same thing before, and I get the same error now. Or actually the game just freezes. But I can't figure out what I do wrong.
    I have everything working, untill I put (saveSlot) instead of (1)
    After I have set up the parameters ofcourse.

    I have this now
    Code:
    (function() {
    
        var params = PluginManager.parameters("JDN_AutoSavePlusTEST.js");
        var saveSlot = Number(params["Auto Save Slot"]);
        var commonEventTr = Number(params["Common Event On Transfer"]);
        var commonEventLvl = Number(params["Common Event On Level Up"]);
      
      
        var _Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;
        Game_Interpreter.prototype.pluginCommand = function(command, args) {
            _Game_Interpreter_pluginCommand.call(this, command, args);      
          
                if(command == 'JDNForceLoad') {
                     if (DataManager.isAnySavefileExists() == true){
                     SceneManager.push(Scene_Load);
                         }
                    else {
                      DataManager.setupNewGame();
                    SceneManager.goto(Scene_Map);
                              }
                }
                if(command == 'JDNForceSave') {
                    $gameSystem.onBeforeSave();
                        DataManager.saveGame(saveSlot);              
                }
    };  
      
    Game_Interpreter.prototype.command201 = function() {
            $gameTemp.reserveCommonEvent(commonEventTr);
        };
    
    Game_Actor.prototype.levelUp = function() {
        $gameTemp.reserveCommonEvent(commonEventLvl);
    };  
    })();
  7. Drop the .js from the file name when reading the parameters and make sure that "Auto Save Slot" matches exactly with what you put on the @param line.

    Just below this:
    Code:
       var params = PluginManager.parameters("JDN_AutoSavePlusTEST");
    Add this line:
    Code:
    console.log(params);
    Open up the console with F8 and make sure that the params variable got created correctly. You can also experiement by typing code directly into the console to test. You can remove the console.log line once it's working.