Jump to content
New account registrations are disabed. This website is now an archive. Read more here.
zahraa

Savefile Path (solved by foreverzer0)

Recommended Posts

i want to save my game's savefile in a folder that called "Games" for example.not same as game folder.i want something like aveyond's savefile path

i searched at google for this script and i found one answer but it made me confusewacko.png .please write a easy answer as it possible

aveyond savefile location:wink.png

 

Vista & 7:

C:\Users\[username]\AppData\Roaming\Aveyond II

 

XP:

C:\Documents and Settings\[username]\Application Data\Aveyond II

 

REALLY sorry for bad english blush.png

Edited by zahraa

Share this post


Link to post
Share on other sites

You need to change the make_filename method in the Scene_File class, and add a path to the filenames it creates.

 

For example, say you'd want to put your savegames in C:\MyFolder, you'd write:

 

 

 def make_filename(file_index)
   return "C:/MyFolder/Save#{file_index + 1}.rxdata"
 end

 

Now you're asking for something difficult, because the Application Data folders aren't constant, they change according to the username, as you noted, which forces you to ask Windows for their path. You can achieve that using environment variables:

 

ENV['HOMEDRIVE']  #=> "C:"
ENV['HOMEPATH']  #=> "/Documents and Settings/Moonpearl"

 

Thus, the following should work:

 

 

 def make_filename(file_index)
   return "#{ENV['HOMEDRIVE']}#{ENV['HOMEPATH']}/Application Data/Aveyond II/Save#{file_index + 1}.rxdata"
 end

Share this post


Link to post
Share on other sites

i did it.but it can't open savefile.i went to savefile's folder that i made and i saw savefile there.but when i open project,it show no load file.also,when i open my project and save a file and back to menu,then go back to save screen again,there is no load file.

if my meaning is unclear,tell me and i will capture a video from my problem.ermm.gif

Share this post


Link to post
Share on other sites

oh,i missed it:

my laptop windows is 7,so i used the path that made for 7,but if someone that use xp want to save game,what will happen?should i write either ways in script?and what about username?if my Laptop username is A and someone else use B as username,can computer find the path for both of them?

Share this post


Link to post
Share on other sites

Try this:

 



module AppData

 GAME_TITLE = "My Game"

 def self.make_filename(index)
   dir = "#{ENV['LOCALAPPDATA']}\\#{GAME_TITLE}"
   Dir.mkdir(dir) unless File.directory?(dir)
   return "#{dir}\\Save#{index + 1}.rxdata"
 end
end
class Scene_File

 def make_filename(index)
   return AppData.make_filename(index)
 end
end
class Scene_Title

 alias check_appdata_files update
 def update
   if @checked == nil
  (0..3).each {|i|
    if FileTest.exist?(AppData.make_filename(i))
	  @continue_enabled = true
	  @command_window.refresh
	  break
    end
  }
  @checked = true
   end
   check_appdata_files
 end
end
class Window_SaveFile

 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 = AppData.make_filename(@file_index)
   @time_stamp = Time.at(0)
   @file_exist = FileTest.exist?(@filename)
   if @file_exist
  file = File.open(@filename, "r")
  @time_stamp = file.mtime
  @characters = Marshal.load(file)
  @frame_count = Marshal.load(file)
  @game_system = Marshal.load(file)
  @game_switches = Marshal.load(file)
  @game_variables = Marshal.load(file)
  @total_sec = @frame_count / Graphics.frame_rate
  file.close
   end
   refresh
   @selected = false
 end
end

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...