Override Save Location

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
Override Save Location v1.0
Shaz
Introduction
This script creates a folder with the same name as your game in the player’s AppData/Roaming folder, and subsequently puts save files in that location.

This means multiple players can use the same PC, under their own profile, and keep their save files private (and safe from accidental overwriting). Players can also uninstall, reinstall or overwrite your game with a new version, and their save files will be unaffected.

How to Use
Paste into a new script slot below Materials. That's it.

Script
Download Here

Compatibility
This script overrides the save_file_exists? and make_filename methods of DataManager. If you have scripts that alias those methods, this script should go above them. If you have scripts that overwrite those methods, you will have to compare the two and make changes to the lowest script to incorporate both lots of modifications.


Credit and Thanks
- Shaz

Author's Notes
Free to use in commercial games.
Give credit.

There MAY be issues with this script if the logon name for the computer contains international characters. I have not been able to test for this yet, so please post here if you do come across this issue.
 
Last edited by a moderator:

Yato

(aka Racheal)
Veteran
Joined
Mar 17, 2012
Messages
825
Reaction score
346
Primarily Uses
Shaz, you make such wonderfully practical scripts. <3
 

ShinGamix

DS Style 4Ever!
Veteran
Joined
Mar 18, 2012
Messages
3,905
Reaction score
451
First Language
April Fools
Primarily Uses
N/A
Oops! Google Chrome could not find ezmash.net

Can't find the script? 

edit-Had to access a cashed version of ezmash.net blog to get to it.

edit2- the cashed version only had the home page cashed...crap. need the script asap.

Finally got it but through a different means.

@Shaz What if I wanted it to save to a folder named Saves in the main Folder list instead of how you have it set up?
 
Last edited by a moderator:

Zane

Food for thought
Veteran
Joined
Jun 9, 2013
Messages
913
Reaction score
110
First Language
US English
Primarily Uses
@shin check that other thread [ACE] Override Save Location I posted a snip it for the other guy there.
 

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,564
Reaction score
3,846
First Language
English
I think this would be easier for users to use.

Place it under the script.

Of course if you know how to modify the script you can see that all I did was change one line and pulled it into a constant.

Code:
module DataManager  #Save_Folder = ENV['APPDATA'] + "\\" + title  Save_Folder = "Saves"  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 = Save_Folder     Dir.mkdir(@savePath) if !File.exists?(@savePath)    @savePath.gsub!(/\\/, '/')  end
 

ShinGamix

DS Style 4Ever!
Veteran
Joined
Mar 18, 2012
Messages
3,905
Reaction score
451
First Language
April Fools
Primarily Uses
N/A
Now the script and scriplet make this perfect for what I wanted.

Going to test it out now.

@Tsukihime I think you need one more End line at the end of your code

It errored and I added an end and it fixed the problem.

#Override Save Location add-on Snippet#by Tsukihimemodule DataManager #Save_Folder = ENV['APPDATA'] + "\\" + title Save_Folder = "Saves" 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 = Save_Folder Dir.mkdir(@savePath) if !File.exists?(@savePath) @savePath.gsub!(/\\/, '/') end#additional end added by ShinGamixendNow it works for me.

After testing

Now for some reason it saves both in the main location and in the save folder and if i remove the ones from the main folder the tile no longer registers as having save files for a continue.

(also the same with Zanes Scriptlet too.)
 
Last edited by a moderator:

Jomarcenter

jomarcenter-MJM
Veteran
Joined
Apr 24, 2012
Messages
1,270
Reaction score
206
First Language
ENGLISH
Primarily Uses
RMMV
It there any way to put the data in a subfolder.

Ex.

User/AppData/Roaming/Jomarcenter Games/"Game Name"/Savedata

And also a way even if I change the name of the game it can still read the save data from the folder?
 
Last edited by a moderator:

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,564
Reaction score
3,846
First Language
English
Use

Code:
ENV['APPDATA'] + "/YOUR_TITLE/save/"
The script makes it so if you change your title it won't find the saves anymore, so you should just hardcode your title.
 
Last edited by a moderator:

Solistra

Veteran
Veteran
Joined
Aug 15, 2012
Messages
593
Reaction score
247
Primarily Uses
Is there any practical reason to be reading the game's title from the INI file instead of simply getting it from the internal RPG::System instance? It would greatly simplify things and access the information from memory rather than having to get it from the disk. Honestly, the only reason I can think of to use the INI file is because that can be easily modified by the user, but that seems like more of a problem than something to cater to in my opinion.

Anyway, this is what your most complicated method would look like using my suggestion (if you're interested):

Code:
def self.create_app_paths  @savePath = ENV['APPDATA'].dup << "\\#{$data_system.game_title}"  Dir.mkdir(@savePath) unless File.directory?(@savePath)  @savePath.gsub!(/\\/, '/')end
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
Multiple stacked folders need a bit more work - each one has to be created.


If you have a folder within the project and are not saving to AppData, you can get rid of the ini file stuff.


Shin, you just picked a bad time. Apparently my host migrated my site to a new server in the last couple of days. The new details are probably still propagating around. I'll check it when I get home this afternoon though, and make sure I don't have to redirect anything manually.


Edit: interesting Solistra. That's a trick I was not aware of. I'll certainly have a play with that - it might even overcome the "foreign characters" issue.
 
Last edited by a moderator:

Jomarcenter

jomarcenter-MJM
Veteran
Joined
Apr 24, 2012
Messages
1,270
Reaction score
206
First Language
ENGLISH
Primarily Uses
RMMV
It is possible to name the save data and it's extension differently?

from Save#.rvdata2 to (Other name).(Other Extension)

Because I try to do this with your script and it really works.

But then again when it reaches to the end-user it may end up in a very bad situation.

And also do you have any plans to make the script a little easier.

Like separating What to type when putting in a folder, Changing Editable Stuff, etc...

I don't have any problem modifying the current script since I can understand it. But I it rather complicated for a few.

Here what I changed in the code:

#-------------------------------------------------------------------------- # * Determine Existence of Save File #-------------------------------------------------------------------------- def self.save_file_exists? !Dir.glob(@savePath + '/SevenTowerSave*.FHData').empty? #Changed end #-------------------------------------------------------------------------- # * Create Filename # index : File Index #-------------------------------------------------------------------------- def self.make_filename(index) sprintf(@savePath + "/SevenTowerSave%02d.FHData", index + 1) #Changed endSaveChange 001.PNG
 
Last edited by a moderator:

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,682
Reaction score
3,003
First Language
Tagalog
Primarily Uses
RMVXA
It is possible, no matter what file extension you use, the game will still save it using the same method so the game can still read it... :)
 

ShinGamix

DS Style 4Ever!
Veteran
Joined
Mar 18, 2012
Messages
3,905
Reaction score
451
First Language
April Fools
Primarily Uses
N/A
Is my issue cause by using a title screen script?
 

Solistra

Veteran
Veteran
Joined
Aug 15, 2012
Messages
593
Reaction score
247
Primarily Uses
Edit: interesting Solistra. That's a trick I was not aware of. I'll certainly have a play with that - it might even overcome the "foreign characters" issue.
I have no idea if it would have any effect on foreign characters interfering with the process. Maybe, maybe not -- I get the feeling that foreign characters may have to be handled by the Win32API and how Windows itself handles them (Ruby is a more *nix-centric language in general), but I'm honestly not certain. I've never dealt with that problem myself.


Anyway, I just suggested that because it seemed like a simpler, more efficient way to do what was being done by reading the INI file. The functionality was the same based on the small amount of testing that I did, and the code was cleaner -- to me, that indicates a better way of doing things.


Really, though, there may be reasons to read from the INI file that I'm not personally aware of, and it may end up being the overall best solution. I honestly don't know.
 

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,682
Reaction score
3,003
First Language
Tagalog
Primarily Uses
RMVXA
Multiple stacked folders need a bit more work - each one has to be created.
Yeah, that was why on my custom data system, I made it such that you input each folder stack into an array so that it can easily be looped and created in order... XD


@Shin - maybe you actually have another save location modifier script in there somewhere?
 
Last edited by a moderator:

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
Shin, title screens don't save, normally. I'm not sure why it's saving in both places - unless you've done something a little unusual when calling the save script. Actually, do you HAVE any custom file load/save scripts?


Might be worth starting a new topic in script support, and posting links to any scripts you're using that have to do with save files.
 

Blue001

Veteran
Veteran
Joined
Jan 13, 2014
Messages
231
Reaction score
112
First Language
English
Primarily Uses
RMMV
Are there any similar scripts to this one that allow for multiple player profiles in a game WITHOUT needing to change your windows log-on? This seems close to what I need, but not quite.

I am making a game that auto-saves the current players progress as it is a rogue-like. The only progress that proceeds from one play-through to the next is scores, and unlocks.

But I don't want every player who plays the game on one computer to use the same save (as they would all share the same unlocks... regardless of who unlocked them and that may ruin the fun for a new player who shares a computer with a veteran one.)

I want a system where when you start the game you choose a profile. It loads the most recent save automatically, for the player, and also allows me to force save using a script call at appropriate times.

Then if another player plays, they can either load a profile or make a new one. This also means no one will accidentally save OVER someone else's save.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
When you first launch the game and choose Continue, how will it know which profile to use? This script would only require a small mod to put/get save files in a particular folder (one folder for each profile), but you would need a completely separate script to create and choose the profiles.
 

Blue001

Veteran
Veteran
Joined
Jan 13, 2014
Messages
231
Reaction score
112
First Language
English
Primarily Uses
RMMV
I looked around, and no one has made a "profile system" yet that I can tell. Zelda 1's system, or Mario 64's is kind of what I want.

In RMVXace terms, The 'profiles' would still be normal save game files. The only difference that makes them a profile rather than a save is that you will never get to choose when or where you save after you load. Selecting "new game" would automatically create a new save in an empty slot. And continue would just bring up a list of the saved games (profiles) already present. They don't need to save in a different folder (except of course if I wanted to protect against deletion like your script here does.)

So I suppose I would also need to find a way to put the "last save slot loaded" in a variable (if that's even possible) so I can save to it directly with auto-save after it's loaded. And figure out if there is a way to check for an empty save slot to use for a new game... XD
 

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

Latest Threads

Latest Posts

Latest Profile Posts

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'??
Yay, now back in action Happy Christmas time, coming back!






Back in action to develop the indie game that has been long overdue... Final Fallacy. A game that keeps on giving! The development never ends as the developer thinks to be the smart cookie by coming back and beginning by saying... "Oh bother, this indie game has been long overdue..." How could one resist such? No-one c

Forum statistics

Threads
105,857
Messages
1,017,018
Members
137,563
Latest member
MinyakaAeon
Top