Custom Save File Location

Status
Not open for further replies.

starlord

Lead (Emma)
Veteran
Joined
Oct 26, 2013
Messages
125
Reaction score
18
First Language
Taglish
Primarily Uses
RMMV
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?
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
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.

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
 
Last edited by a moderator:

starlord

Lead (Emma)
Veteran
Joined
Oct 26, 2013
Messages
125
Reaction score
18
First Language
Taglish
Primarily Uses
RMMV

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
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.
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,712
First Language
English
Primarily Uses
RMVXA
[mod]Being temporarily reopened so that the formatting problem with the script can be resolved.[/mod]

@tv.ghost When you've finished please Report this post and ask for the thread to be closed again. Thanks.
 

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
5,592
Reaction score
6,522
First Language
Indonesian
Primarily Uses
RMVXA
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
 

ZirconStorms

Veteran
Veteran
Joined
Dec 22, 2014
Messages
359
Reaction score
111
First Language
English
Primarily Uses
RMVXA
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.
 

slimmmeiske2

Little Red Riding Hood
Global Mod
Joined
Sep 6, 2012
Messages
7,842
Reaction score
5,225
First Language
Dutch
Primarily Uses
RMXP

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.

 
Status
Not open for further replies.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,865
Messages
1,017,059
Members
137,575
Latest member
akekaphol101
Top