Save-Point

Full Version: Save-Point
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Board Message
Sorry, you do not have permission to access this resource.
Save-Point - Environment Path

Save-Point

Full Version: Environment Path
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
hi there again, i want to save my savvegames in the My Games folder like real games do that.
i tryed %PATH% and [PATH] allready but it doesnt work...
how can i use an environment path in rmxp ? (some games can that)
and if it works how can i check if the folder exists and if it not exists make rmxp to create it ?
because it crashes when a folder not exists...

thx alot in advance
The following sets up a game folder within your Documents and Settings "Application Data" folder, like more and more games use. ^_^ How's that?

You'll need something like this that is run before you actually see the title screen. Very likely at the start of Scene_Title, but also in a Title Skip script if applicable.

Code:
# Set the name of your game folder
    GAME_FOLDER = "Buddy_Game"
    # Create Path Where Folder Should Be Created
    path = " " * 256
    path = ENV['AV_APPDATA'].rstrip
    $appPath = path.to_s + "\\"+ GAME_FOLDER
    # Create Your Folder
    if !File.exists?($appPath)  
      Dir.mkdir($appPath)
    end

That would first set a $app_Path folder you'll need here and there and make your folder if it doesn't exist.

In the Window_SaveGame class, you'll need this...
Code:
#--------------------------------------------------------------------------
  # * Object Initialization
  #     file_index : save file index (0-3)
  #     filename   : file name
  #--------------------------------------------------------------------------
  def initialize(file_index, filename)
    super(0, 64 + file_index % 4 * 104, 640, 104)
    self.contents = Bitmap.new(width - 32, height - 32)
    @file_index = file_index
    @filename = $appPath + "/" + "Save#{@file_index + 1}.rxdata" # HERE IS THE EDIT
    @time_stamp = Time.at(0)

Look in Scene_Title's main method, and you're sure to see where this is changed
Code:
@continue_enabled = false
    for i in 0..3
      if FileTest.exist?($appPath + "/" + "Save#{i+1}.rxdata")
        @continue_enabled = true
      end
    end

And the Scene_File class has a method changed around to this
Code:
def make_filename(file_index)
    return $appPath + "/" + "Save#{file_index + 1}.rxdata" # Commercial Script
  end

thx alot works well Winking
solved...
Lemme revive this thread by giving a warning about using the %AppData% environment variable, Dir['AppData'] , to get the Roaming application data file path for the current user.

It doesn't work too well with some user names. Probably an issue with Ruby's handling of double byte characters.
Anyway, Amanda's commercial game script solves the issue by creating a new environment through a custom dll which puts in the shortname version of the path (The good old 8.3)
Even this is not failsafe. I have seen it fail for some CJK characters.

So if you want to use this I highly suggest creating a fall-back option where it can store saves games in another place. Perhaps as a sub-folder of the working direction. Of course, if that is under "c:\program files" there may still be problems with permissions.

So be careful about handling fail situations in the save system.

*hugs*