Custom Save File Location

Can someone make me a script that has that can save the saved game file to the App Data folder in the Users Folder in Local Disk C?
This script creates a folder with the same name as your game, in the user's %appdata% folder (AppData/Roaming, to be exact), if it doesn't already exist, and subsequently puts all the save files there.

So if your game is called Greatest Game on Earth, the save files will go into user/AppData/Roaming/Greatest Game on Earth

I am not sure if this will have issues if the user name has international characters.  I recall we used to, way back when, but I'm not sure if this was the cause, and I haven't tested the Ace version of the script to see if it still happens.

NOTE: This overwrites a couple of methods in DataManager, so if you have other scripts that also alias or overwrite those methods, you'll need to look at the two very closely to determine what needs to be done.

Spoiler
Code:
module DataManager  class << self    alias shaz_custom_save_datamanager_init init  end  #--------------------------------------------------------------------------  # * Initialize Module  #--------------------------------------------------------------------------  def self.init    shaz_custom_save_datamanager_init    create_app_paths  end  #--------------------------------------------------------------------------  # * Create Custom Save Path  #--------------------------------------------------------------------------  def self.create_app_paths    title = "\0" * 256    readini = Win32API.new('kernel32', 'GetPrivateProfileStringA', %w(p p p p l p), 'l')    readini.call('Game', 'Title', '', title, 255, '.\\Game.ini')    title.delete!("\0")    @savePath = ENV['APPDATA'] + "\\" + title    Dir.mkdir(@savePath) if !File.exists?(@savePath)    @savePath.gsub!(/\\/, '/')  end  #--------------------------------------------------------------------------  # * Determine Existence of Save File  #--------------------------------------------------------------------------  def self.save_file_exists?    !Dir.glob(@savePath + '/Save*.rvdata2').empty?  end  #--------------------------------------------------------------------------  # * Create Filename  #     index : File Index  #--------------------------------------------------------------------------  def self.make_filename(index)    sprintf(@savePath + "/Save%02d.rvdata2", index + 1)  endend
thanks!  😀
This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.
Moderator note: Being temporarily reopened so that the formatting problem with the script can be resolved.

@tv.ghost When you've finished please Report this post and ask for the thread to be closed again. Thanks.
Code:
module DataManager 
  class << self   
    alias shaz_custom_save_datamanager_init init 
  end 
  #-------------------------------------------------------------------------- 
  # * Initialize Module 
  #-------------------------------------------------------------------------- 
  def self.init   
    shaz_custom_save_datamanager_init   
    create_app_paths 
  end 
  #-------------------------------------------------------------------------- 
  # * Create Custom Save Path 
  #-------------------------------------------------------------------------- 
  def self.create_app_paths   
    title = "\0" * 256   
    readini = Win32API.new('kernel32','GetPrivateProfileStringA',
      %w(p p p p l p), 'l')   
    readini.call('Game', 'Title', '', title, 255, '.\\Game.ini')   
    title.delete!("\0")   
    @savePath = ENV['APPDATA'] + "\\" + title   
    Dir.mkdir(@savePath) if !File.exists?(@savePath)   
    @savePath.gsub!(/\\/, '/') 
  end 
  #-------------------------------------------------------------------------- 
  # * Determine Existence of Save File 
  #-------------------------------------------------------------------------- 
  def self.save_file_exists?   
    !Dir.glob(@savePath + '/Save*.rvdata2').empty? 
  end 
  #-------------------------------------------------------------------------- 
  # * Create Filename 
  #   index : File Index 
  #-------------------------------------------------------------------------- 
  def self.make_filename(index)   
    sprintf(@savePath + "/Save%02d.rvdata2", index + 1) 
  end
end
Code:
module DataManager
  class << self  
    alias shaz_custom_save_datamanager_init init
  end
  #--------------------------------------------------------------------------
  # * Initialize Module
  #--------------------------------------------------------------------------
  def self.init  
    shaz_custom_save_datamanager_init  
    create_app_paths
  end
  #--------------------------------------------------------------------------
  # * Create Custom Save Path
  #--------------------------------------------------------------------------
  def self.create_app_paths  
    title = "\0" * 256  
    readini = Win32API.new('kernel32','GetPrivateProfileStringA',
      %w(p p p p l p), 'l')  
    readini.call('Game', 'Title', '', title, 255, '.\\Game.ini')  
    title.delete!("\0")  
    @savePath = ENV['APPDATA'] + "\\" + title  
    Dir.mkdir(@savePath) if !File.exists?(@savePath)  
    @savePath.gsub!(/\\/, '/')
  end
  #--------------------------------------------------------------------------
  # * Determine Existence of Save File
  #--------------------------------------------------------------------------
  def self.save_file_exists?  
    !Dir.glob(@savePath + '/Save*.rvdata2').empty?
  end
  #--------------------------------------------------------------------------
  # * Create Filename
  #   index : File Index
  #--------------------------------------------------------------------------
  def self.make_filename(index)  
    sprintf(@savePath + "/Save%02d.rvdata2", index + 1)
  end
end
Well, you beat me to it, lol.

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/custom-save-file-location.20055/