Autosave

Discussion in 'RGSS3 Scripts (RMVX Ace)' started by Todd, Jun 22, 2012.

    Tags:
  1. Todd

    Todd Game Developer Member

    Messages:
    269
    Likes Received:
    42
    First Language:
    English
    Primarily Uses:
    N/A
    Autosave 1.0.0

    by Todd (or DoctorTodd on RMRK)

    Introduction

    Change autosave file name to autosave and have an optional window saying the game was autosaved.

    Features

    • Change max files.
    • Call autosave

    How to Use

    Paste above main.

    Configure the script to the way you like it.

    Script

    Code:
    
    #===============================================================================
    #
    # DT's Autosave
    # Author: DoctorTodd
    # Date (06/22/2012)
    # Version: (1.0.0) (VXA)
    # Level: (Simple)
    # Email: Todd@beacongames.com
    #
    #===============================================================================
    #
    # NOTES: 1)This script will only work with ace.
    #
    #===============================================================================
    #
    # Description: Saves the game when transferring the map, before battle,
    # and opening the menu (all optional).
    #
    # Credits: Me (DoctorTodd)
    #
    #===============================================================================
    #
    # Instructions
    # Paste above main.
    # Call using Autosave.call
    #
    #===============================================================================
    #
    # Free for any use as long as I'm credited.
    #
    #===============================================================================
    #
    # Editing begins 37 and ends on 50.
    #
    #===============================================================================
    module ToddAutoSaveAce
    
    	  #Max files (without autosave).
    	  MAXFILES = 16
    
    	  #Autosave file name.
    	  AUTOSAVEFILENAME = "Autosave"
    
    	  #Autosave before battle?
    	  AUTOSAVEBB =  true
    
    	  #Autosave when menu opened?
    	  AUTOSAVEM =  true
    
    	  #Autosave when changing map?
    	  AUTOSAVETM =  true
    	end
    #==============================================================================
    # ** Autosave
    #------------------------------------------------------------------------------
    # This module contains the autosave method. This is allows you to use the
    # "Autosave.call" command.
    #==============================================================================
    
    module Autosave
      #--------------------------------------------------------------------------
      # * Call method
      #--------------------------------------------------------------------------
      def self.call
      DataManager.save_game_without_rescue(0)
    end
    end
    #==============================================================================
    # ** DataManager
    #------------------------------------------------------------------------------
    #  This module manages the database and game objects. Almost all of the
    # global variables used by the game are initialized by this module.
    #==============================================================================
    
    module DataManager
      #--------------------------------------------------------------------------
      # * Maximum Number of Save Files
      #--------------------------------------------------------------------------
      def self.savefile_max
    	return ToddAutoSaveAce::MAXFILES + 1
      end  
    end
    #==============================================================================
    # ** Scene_Map
    #------------------------------------------------------------------------------
    #  This class performs the map screen processing.
    #==============================================================================
    
    class Scene_Map < Scene_Base
      #--------------------------------------------------------------------------
      # * Preprocessing for Battle Screen Transition
      #--------------------------------------------------------------------------
      def pre_battle_scene
    	Graphics.update
    	Graphics.freeze
    	@spriteset.dispose_characters
    	BattleManager.save_bgm_and_bgs
    	BattleManager.play_battle_bgm
    	Sound.play_battle_start
      Autosave.call if ToddAutoSaveAce::AUTOSAVEBB
    end
      #--------------------------------------------------------------------------
      # * Call Menu Screen
      #--------------------------------------------------------------------------
      def call_menu
    	Sound.play_ok
    	SceneManager.call(Scene_Menu)
    	Window_MenuCommand::init_command_position
      Autosave.call if ToddAutoSaveAce::AUTOSAVEM
    end
      #--------------------------------------------------------------------------
      # * Post Processing for Transferring Player
      #--------------------------------------------------------------------------
      def post_transfer
    	case $game_temp.fade_type
    	when 0
    	  Graphics.wait(fadein_speed / 2)
    	  fadein(fadein_speed)
    	when 1
    	  Graphics.wait(fadein_speed / 2)
    	  white_fadein(fadein_speed)
    	end
    	@map_name_window.open
      Autosave.call if ToddAutoSaveAce::AUTOSAVETM
    end
    end
    
    FAQ

    None right now.

    Credit and Thanks

    - Todd

    Author's Notes

    See header
     
    #1
    Badweather4cast, Lee Sang and Bonkers like this.
  2. Spy

    Spy Spy Veteran

    Messages:
    42
    Likes Received:
    56
    Location:
    Belgium
    First Language:
    French
    Hello and thank you for your script

    I get this error when I open the menu:

    Capture.PNG

    Thank you for your help.
     
    Last edited by a moderator: Jun 23, 2012
    #2
  3. Todd

    Todd Game Developer Member

    Messages:
    269
    Likes Received:
    42
    First Language:
    English
    Primarily Uses:
    N/A
    Alright I'll find a solution.

    EDIT:

    What menu and save system are you using? Do you know of any scripts that may cause the problem?
     
    Last edited by a moderator: Jun 23, 2012
    #3
  4. Spy

    Spy Spy Veteran

    Messages:
    42
    Likes Received:
    56
    Location:
    Belgium
    First Language:
    French
    EDIT : I found, the script "Khas Awesome Light Effects" is the problem.

    You have a solution?
     
    Last edited by a moderator: Jun 23, 2012
    #4
  5. Todd

    Todd Game Developer Member

    Messages:
    269
    Likes Received:
    42
    First Language:
    English
    Primarily Uses:
    N/A
    Well the menu script isn't the problem, could you make a copy of your project and remove scripts until the it works?
     
    #5
  6. Spy

    Spy Spy Veteran

    Messages:
    42
    Likes Received:
    56
    Location:
    Belgium
    First Language:
    French
    Lol I just edited the above.

    The problem is the script Khas Awesome Light Effects :)
     
    Last edited by a moderator: Jun 23, 2012
    #6
  7. Todd

    Todd Game Developer Member

    Messages:
    269
    Likes Received:
    42
    First Language:
    English
    Primarily Uses:
    N/A
    Alright I'll see if I can fix it.

    EDIT:

    Weird I can't recreate the error...
     
    Last edited by a moderator: Jun 23, 2012
    #7
  8. Spy

    Spy Spy Veteran

    Messages:
    42
    Likes Received:
    56
    Location:
    Belgium
    First Language:
    French

    Attached Files:

    Last edited by a moderator: Jul 18, 2012
    #8
  9. Todd

    Todd Game Developer Member

    Messages:
    269
    Likes Received:
    42
    First Language:
    English
    Primarily Uses:
    N/A
    That almost gave me a virus. :o

    But yes I see what you mean. I put the autosave script above it and it fixed the menu but not the autosave call. I'll try to fix the autosave call in my next version.
     
    #9
  10. Spy

    Spy Spy Veteran

    Messages:
    42
    Likes Received:
    56
    Location:
    Belgium
    First Language:
    French
    Ok Thank you :)
     
    Last edited by a moderator: Jun 23, 2012
    #10
  11. Jomarcenter

    Jomarcenter jomarcenter-MJM Veteran

    Messages:
    1,231
    Likes Received:
    161
    Location:
    philippines
    First Language:
    ENGLISH
    Primarily Uses:
    RMMV
    #11
  12. Todd

    Todd Game Developer Member

    Messages:
    269
    Likes Received:
    42
    First Language:
    English
    Primarily Uses:
    N/A
    Alright I'll start it tomorrow (It's 1:53 AM where I am and I'm in no mood to script).

    EDIT:

    Sorry Jormarcenter, I've been working on some other stuff. I'll attempt to make them compatible.
     
    Last edited by a moderator: Jun 25, 2012
    #12
  13. Todd

    Todd Game Developer Member

    Messages:
    269
    Likes Received:
    42
    First Language:
    English
    Primarily Uses:
    N/A

    Attached Files:

    #13
    Bonkers and Chaos17 like this.
  14. Jomarcenter

    Jomarcenter jomarcenter-MJM Veteran

    Messages:
    1,231
    Likes Received:
    161
    Location:
    philippines
    First Language:
    ENGLISH
    Primarily Uses:
    RMMV
    thank for the script.
     
    #14
  15. gameguy199

    gameguy199 Villager Member

    Messages:
    25
    Likes Received:
    0
    First Language:
    english
    hello i seem to be having a problem with this script.

    the script is supposed to rename a single file 'autosave'.

    and yet as i look through my files i cannot find the one labled "autosave".

    any ideas why?
     
    #15
  16. Todd

    Todd Game Developer Member

    Messages:
    269
    Likes Received:
    42
    First Language:
    English
    Primarily Uses:
    N/A
    Use this version, the main one is outdated. This version allows you to use these commands in a script call. Make sure to credit both me and ArkLennard.

    Code:
    Autosave.callAutosave.load 
    Code:
    #===============================================================================## DT's Autosave# Author: DoctorTodd# Date (06/22/2012)# Edited by: ArkLennard# Date (01/13/2013)# Version: (1.0.0) (VXA)# Level: (Simple)# Email: Todd@beacongames.com##===============================================================================## NOTES: 1)This script will only work with ace.##===============================================================================## Description: Saves the game when transferring the map, before battle, # and opening the menu (all optional).## Credits: Me (DoctorTodd), ArkLennard##===============================================================================## Instructions# Paste above main.##===============================================================================## Free for any use as long as I'm credited.##===============================================================================## Editing begins 37 and ends on 50.##===============================================================================module ToddAutoSaveAce            #Max files (without autosave).      MAXFILES = 16            #Autosave file name.      AUTOSAVEFILENAME = "Autosave"            #Switch to activate autosave before battle?      AUTOSAVEBB = 1            #Switch to activate autosave when menu opened?      AUTOSAVEM =  2             #Switch to activate autosave when changing map?      AUTOSAVETM =  3             #Variable ID that contains the number where the sutosave file will be saved.      VARIABLE = 1          end#==============================================================================# ** Autosave#------------------------------------------------------------------------------# This module contains the autosave method. This allows you to use the# "Autosave.call" ans "Autosave.load" commands. #==============================================================================module Autosave  #--------------------------------------------------------------------------  # * Save header writer  #--------------------------------------------------------------------------  def self.make_save_header    header = {}    header[:characters] = $game_party.characters_for_savefile    header[:playtime_s] = $game_system.playtime_s    header  end  #--------------------------------------------------------------------------  # * Save contents writer  #--------------------------------------------------------------------------  def self.make_save_contents    contents = {}    contents[:system]        = $game_system    contents[:timer]         = $game_timer    contents[:message]       = $game_message    contents[:switches]      = $game_switches    contents[:variables]     = $game_variables    contents[:self_switches] = $game_self_switches    contents[:actors]        = $game_actors    contents[:party]         = $game_party    contents[:troop]         = $game_troop    contents[:map]           = $game_map    contents[:player]        = $game_player    contents  end    #--------------------------------------------------------------------------  # * Save contents extractor  #--------------------------------------------------------------------------  def self.extract_save_contents(contents)    $game_system        = contents[:system]    $game_timer         = contents[:timer]    $game_message       = contents[:message]    $game_switches      = contents[:switches]    $game_variables     = contents[:variables]    $game_self_switches = contents[:self_switches]    $game_actors        = contents[:actors]    $game_party         = contents[:party]    $game_troop         = contents[:troop]    $game_map           = contents[:map]    $game_player        = contents[:player]  end    #--------------------------------------------------------------------------  # * Map reloader  #--------------------------------------------------------------------------  def self.reload_map_if_updated    if $game_system.version_id != $data_system.version_id      $game_map.setup($game_map.map_id)      $game_player.center($game_player.x, $game_player.y)      $game_player.make_encounter_count    end  end    #--------------------------------------------------------------------------  # * Total fade out  #     time : duration (milliseconds)  #--------------------------------------------------------------------------  def self.fadeout_all(time = 1000)    RPG::BGM.fade(time)    RPG::BGS.fade(time)    RPG::ME.fade(time)    Graphics.fadeout(time * Graphics.frame_rate / 1000)    RPG::BGM.stop    RPG::BGS.stop    RPG::ME.stop  end    #--------------------------------------------------------------------------  # * Call method  #--------------------------------------------------------------------------    def self.call  File.open('Autosave.rvdata2', "wb") do |file|      $game_system.on_before_save      Marshal.dump(make_save_header, file)      Marshal.dump(make_save_contents, file)    end    end            def self.load    fadeout_all    File.open('Autosave.rvdata2', "rb") do |file|    Marshal.load(file)    extract_save_contents(Marshal.load(file))    reload_map_if_updated    end    $game_system.on_after_load    SceneManager.goto(Scene_Map)            end  end#==============================================================================# ** DataManager#------------------------------------------------------------------------------#  This module manages the database and game objects. Almost all of the # global variables used by the game are initialized by this module.#==============================================================================module DataManager  #--------------------------------------------------------------------------  # * Maximum Number of Save Files  #--------------------------------------------------------------------------  def self.savefile_max    return ToddAutoSaveAce::MAXFILES + 1  end  end#==============================================================================# ** Scene_Map#------------------------------------------------------------------------------#  This class performs the map screen processing.#==============================================================================class Scene_Map < Scene_Base  #--------------------------------------------------------------------------  # * Preprocessing for Battle Screen Transition  #--------------------------------------------------------------------------  def pre_battle_scene    Graphics.update    Graphics.freeze    @spriteset.dispose_characters    BattleManager.save_bgm_and_bgs    BattleManager.play_battle_bgm    Sound.play_battle_start  Autosave.call if $game_switches[ToddAutoSaveAce::AUTOSAVEBB] == trueend  #--------------------------------------------------------------------------  # * Call Menu Screen  #--------------------------------------------------------------------------  def call_menu    Sound.play_ok    SceneManager.call(Scene_Menu)    Window_MenuCommand::init_command_position  Autosave.call if $game_switches[ToddAutoSaveAce::AUTOSAVEM] == trueend  #--------------------------------------------------------------------------  # * Preprocessing for Transferring Player  #--------------------------------------------------------------------------  def pre_transfer    @map_name_window.close    case $game_temp.fade_type    when 0      fadeout(fadeout_speed)    when 1      white_fadeout(fadeout_speed)    end  #--------------------------------------------------------------------------  # * Post Processing for Transferring Player  #--------------------------------------------------------------------------  def post_transfer    case $game_temp.fade_type    when 0      Graphics.wait(fadein_speed / 2)      fadein(fadein_speed)    when 1      Graphics.wait(fadein_speed / 2)      white_fadein(fadein_speed)    end    @map_name_window.open  Autosave.call if $game_switches[ToddAutoSaveAce::AUTOSAVETM] == true  end endend
     
    #16
    Lee Sang likes this.
  17. gameguy199

    gameguy199 Villager Member

    Messages:
    25
    Likes Received:
    0
    First Language:
    english
    still doesn;t rename the file.

    and now it doesn;t save when i walk into a new area.

    did not fix anything.
     
    Last edited by a moderator: Jun 27, 2013
    #17
  18. Ozuma

    Ozuma Villager Member

    Messages:
    19
    Likes Received:
    5
    Hello Casper!


    First I would like to congratulate you for the great work.


    I would like to use this script of yours, but just need a part of it:


    I want the autosave is the ONLY way to save the game. In other words, there is only one save slot, and I'll EVENTS IN call Script (DataManager.csca_autosave :) save)), and the player will be informed that the game was saved.


    Thus, I put false at all the options to automatically save even more for the Title Screen "Load Autosave". I want the conventional option "Load" to load the autosave!


    Thanks in advance and sorry for the bad english.
     
    #18
  19. Todd

    Todd Game Developer Member

    Messages:
    269
    Likes Received:
    42
    First Language:
    English
    Primarily Uses:
    N/A
    If I have some free time I will. No need to apologize for your English it's actually very good but my name is Todd. 
     
    #19
  20. Ozuma

    Ozuma Villager Member

    Messages:
    19
    Likes Received:
    5
    Hey Todd!

    I do not want you to think I'm rushing you or anything, I just gosaria wonder if you can do something about what I had asked, and if you have any idea when to get ready.

     

    Sorry to call you "Casper" the first time kkk

    And thanks again.
     
    #20

Share This Page