• Just a reminder that providing specifics on, sharing links to, or naming websites where ROMs can be accessed is against the rules. If your post has any of this information it will be removed.
  • Ever thought it'd be cool to have your art, writing, or challenge runs featured on PokéCommunity? Click here for info - we'd love to spotlight your work!
  • Our weekly protagonist poll is now up! Vote for your favorite Conquest protagonist in the poll by clicking here.
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

Autosave function

  • 1,224
    Posts
    11
    Years
    In Scene_Map, under def update , add this inside the loop (being inside the loop is very important)

    Spoiler:

    This is what actually keeps track of the time and calls the save.
    It uses a couple variables, so we need to set those. In class PokemonGlobalMetadata, we add these along with the other accessors

    Code:
    attr_accessor :autosave
      attr_accessor :autosavetimer

    and then set them in the class' initialize function (def initialize)

    Code:
    @autosave             = true
        @autosavetimer        = 300
    This sets the autosave on, and its timer to 300 seconds.

    To allow the player to change this on and off, and to change the time, we'll add this option to PokemonOptions in class PokemonOptionScene
    Spoiler:
    This should be pretty obvious where it goes.

    Very last step, add this to PokemonSave under def pbSave
    Spoiler:

    This will save the game for the player in a separate file "Game_autosave" in the same place as the regular save, so that the user can easily change the name and use it as their main save. You can also easily add in a couple lines to save it as a regular files as well, or replace "if pbAutoSave" to "if pbSave" to have it only save normally.

    Note that this will not work unless you start a new game, since the it has to initialize the PokemonGlobalMetadata class, which it only does when you start a new game.

    This goes by your computer's clock, so it will count regular seconds even for things like FL's Unreal Time System.


    If syntax errors(edit: there are, at least in Chrome), use Show Printable Version under Thread Tools to get unformatted text.

    Also, you might have to add a $scene=Scene_Map.new to several pbEndScene methods to force it to start again. Not sure how what this part affects in gameplay, or that it is necessary.
     
    Last edited:
    Nice feature!

    Some tips for your scripts:
    • 'if $PokemonGlobal.autosave==true' or 'if $PokemonGlobal.autosave==false' are slower (RGSS is interpreted, right?) and uglier commands than 'if $PokemonGlobal.autosave' or 'if !$PokemonGlobal.autosave'.
    • 'Kernel.pbMessage("Save failed.")' can't be translated using Essentials translate tool. When making tutorials, please put all the translatable text in _INTL/_ISPRINTF or _I for events text.
    • This is optional, but I prefer using ternary operator like 'Kernel.pbMessage(pbAutoSave ? _INTL("{1} saved the game",$Trainer.name) : _INTL("Save failed."))' instead of

      Code:
      if pbAutoSave #new save function, saves as Game_autosave
        Kernel.pbMessage(_INTL("{1} saved the game",$Trainer.name))
      else
        Kernel.pbMessage(_INTL("Save failed."))
      end

    Coincidence or not, KaysCollapse also creates a script for the same feature some days ago.
     
    Nice feature!

    Some tips for your scripts:
    • 'if $PokemonGlobal.autosave==true' or 'if $PokemonGlobal.autosave==false' are slower (RGSS is interpreted, right?) and uglier commands than 'if $PokemonGlobal.autosave' or 'if !$PokemonGlobal.autosave'.
    • 'Kernel.pbMessage("Save failed.")' can't be translated using Essentials translate tool. When making tutorials, please put all the translatable text in _INTL/_ISPRINTF or _I for events text.
    • This is optional, but I prefer using ternary operator like 'Kernel.pbMessage(pbAutoSave ? _INTL("{1} saved the game",$Trainer.name) : _INTL("Save failed."))' instead of

      Code:
      if pbAutoSave #new save function, saves as Game_autosave
        Kernel.pbMessage(_INTL("{1} saved the game",$Trainer.name))
      else
        Kernel.pbMessage(_INTL("Save failed."))
      end

    Coincidence or not, KaysCollapse also creates a script for the same feature some days ago.


    Thanks, included your suggestions! And it actually is coincidence, I had not seen that.
     
    Hey, if I use this, and someone is in a battle for more than 5 minutes, would it save mid battle?

    It should not. In Scene_Map the lines
    Code:
    if $scene != self
    break
    Should stop the update from running, which is where it does its checks. Similar to how you can't access your menu by pressing B when you're in battle or in a different scene. It's not checking for that because the loop was broken.
     
    Back
    Top