Override Save Location

● ARCHIVED · READ-ONLY
Started by Shaz 20 posts View original ↗
  1. 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.
  2. Shaz, you make such wonderfully practical scripts. <3
  3. I second that!
  4. 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?
  5. @shin check that other thread [ACE] Override Save Location I posted a snip it for the other guy there.
  6. 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
  7. 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.)
  8. 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?
  9. 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.
  10. 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
  11. 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.
  12. 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 end SaveChange 001.PNG
  13. 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... :)
  14. Is my issue cause by using a title screen script?
  15. Shaz said:
    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.
  16. 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?
  17. 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.
  18. 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.
  19. 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.
  20. 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