Submit Your Article


 
RPG Maker

Welcome Guest ( Log In | Register )


  Games Resources RPG Maker VX RPG Maker XP Scripts Tutorials Downloads

 
Reply to this topicStart new topic
> Super Simple Custom Save System (VX)
amaranth
post Aug 19 2009, 02:14 PM
Post #1


Level 6
Group Icon

Group: Member
Posts: 78
Type: Developer
RM Skill: Masterful




Introduction
If you are using Vista, you have probably already learned by now that unless you are logged in with administrator permissions, you cannot write or update data in the Programs Files directory. Any user who installs their RPG Maker VX game in this directory will not be able to save their games or update their game option files.

So what are we to do, eh? Yes, Vista is new, and it's a real pain in the arse, but like it or not, it's not going to go away. Best to prepare for the future, I say.

Let the fun begin!

Demo
Download Demo Here

Step 1: Put Utils.dll in your project's folder
At the bottom of this post is a ZIP that contains Utils.dll. Download and Unzip this file into the directory for your game. If you've done this right, Utils.dll will appear beside your game.exe in the directory for your game.

Step 2: Create Game Directory On Startup
The first time that your user runs your game, a directory needs to be created for them that is local to their account. We will use this directory for our save files and any other files that needs to be modified by players.

The following code gets a path to a user's directory. Then it creates a directory for your game. The directory is only created the first time that the user plays the game.

The directory must be local to the user's machine. (which is why I have used the WinAPI below).

1. Open the script editor for your project and go to Main.
2. Add the following code under begin:
CODE
#------------------------------------
# Folder Settings
#------------------------------------  
# Create Your Folder  
SetEnv = Win32API.new('Utils', "AVSetEnv", ["V"], "I")
env = SetEnv.call
raise "UTILS: AVSetEnv failed!" if (!env)
    
path = " " * 256
path = ENV['AV_APPDATA'].rstrip
$appPath = path.to_s + "\\Aveyond 3"    
  
# Create Your Folder
if !File.exists?($appPath)  
  Dir.mkdir($appPath)
end


Note: This points to the user's Application Data directory. On Windows XP, this constant points to this directory: C:\Documents and Settings\All Users\Application Data. The value for this constant changes, depending upon the operating system. This means that there is no need to hard-code anything!

Step 3: Point Your Save Game Files To The New Directory
Now that you have dynamically created a directory for your user, you need to make sure that your save files write to this directory, and not to your game's directory.

1. In Window_SaveFile, on line 23...

Replace this:
CODE
@filename = filename


With this:
CODE
@filename = $appPath  + "\\" + "Save#{@file_index}.rvdata"


2. In Scene_Title, on line 130...

Replace this function:
CODE
  def check_continue
     @continue_enabled = (Dir.glob('Save*.rvdata').size > 0)
  end


With this function:
CODE
  def check_continue
     for i in 0..8
      if FileTest.exist?($appPath + "\\" + "Save#{i}.rvdata")
        @continue_enabled = true
      end
    end
  end


3. In Scene_File, on line 158...

Replace this:
CODE
return "Save#{file_index + 1}.rvdata"


With this:
CODE
return $appPath + "\\" + "Save#{file_index}.rvdata"


And that's that! If you have created an options file for your game, follow the same steps for it. smile.gif

Credits
Special credit should be given to Eccid. I wasn't sure how to get the ball rolling onto this one until I saw his save script over at Creation Asylum

This post has been edited by amaranth: Feb 1 2010, 11:39 AM
Attached File(s)
Attached File  SaveSystemVX.zip ( 276.06K ) Number of downloads: 110
Attached File  Utils.zip ( 37.67K ) Number of downloads: 40
 


__________________________
Go to the top of the page
 
+Quote Post
   
icecold49
post Aug 23 2009, 12:24 AM
Post #2


My rmvx project is taking longer than I expected...
Group Icon

Group: Revolutionary
Posts: 116
Type: Developer
RM Skill: Advanced




Well this kinda neat. I myself use windows XP but this should be really useful for all you VX users who suffer with this saving problem. Thanks for the submission.

This post has been edited by icecold49: Aug 23 2009, 12:25 AM


__________________________
Go to the top of the page
 
+Quote Post
   
Zeriab
post Aug 23 2009, 02:52 AM
Post #3


Level 12
Group Icon

Group: Revolutionary
Posts: 196
Type: Event Designer
RM Skill: Skilled




I like idea of trying to avoid saving problems with Vista biggrin.gif
What is important to note is that you can have a case where you do not have permission to write and/or read from the application data folder.
I am not too fond of creating a new environment variable when there is one present by standard in XP and Vista. (Dunno about earlier versions)

Personally I would use this version to determine where the saves are:
CODE
begin
  path = ENV['AV_APPDATA']
  $appPath = path.to_s + "\\YourGame"
  if !File.exists?($appPath)
    Dir.mkdir($appPath)
  end
rescue
  # Perhaps tell the player that there is a problem
  $appPath = "." # Use current directory
end


The reason for the rescue is to heighten the chance of the players being able to play the game.
An alternative choice or one that could be used in conjunction is to give the player the choice to change the location of the save files. It could for example be present in the game.ini file.

I think you have a good idea. I just think it can be improved happy.gif
*hugs*
- Zeriab


__________________________
Go to the top of the page
 
+Quote Post
   
buny
post Aug 23 2009, 04:10 AM
Post #4


Level 15
Group Icon

Group: Revolutionary
Posts: 294
Type: Developer
RM Skill: Intermediate




Demo...demo demo...demo demoooo


__________________________







Topic'Z

VLAD REQUIEM IS UPDATE! to ~8~
The TopicszZ


@~Action Battle System~@


[Show/Hide] Action Battle System
Bored Battle System Like This
[Show/Hide] Normal Style


So Do you liem MMORPG style?or Zelda?
if yes you'll need this...
style~>
[Show/Hide] Requiem SABS


Join Here ABS


@###@@@###@#
@####@##@##@##
@@#@@@##@@


[Show/Hide] good again
[Show/Hide] NEVER GIVE UP
[Show/Hide] DONT WASTE MY TIME AGAIN!!!!!!!!!!!!!!!!!!!!
[Show/Hide] LASSSSTTTTT ONE
clever you are the 99999999 visitors who open this get outta here!!!!!
Go to the top of the page
 
+Quote Post
   
platipus
post Aug 25 2009, 03:59 AM
Post #5


Level 11
Group Icon

Group: Revolutionary
Posts: 191
Type: Event Designer
RM Skill: Skilled




what's the benefits of using this "super simple" custom save system?
any screenshot?


__________________________
using xp now and will continue to until a better rpg maker
Go to the top of the page
 
+Quote Post
   
redyugi
post Aug 25 2009, 04:41 AM
Post #6


Python Programmer
Group Icon

Group: Revolutionary
Posts: 126
Type: Scripter
RM Skill: Intermediate




What this is used for, Platipus, is to work around Vista's annoying habit of needing password input to write files or access files. This really should be renamed because I thought it was something different too. That being said, I am not using this, mainly because I finally got rid of Vista, and I am done with finding ways around it. lolz


__________________________
Go to the top of the page
 
+Quote Post
   
platipus
post Aug 25 2009, 08:08 AM
Post #7


Level 11
Group Icon

Group: Revolutionary
Posts: 191
Type: Event Designer
RM Skill: Skilled




@redyugi

ah okay got it. :]

i dont think i'll be needing it since im not a vista user.


__________________________
using xp now and will continue to until a better rpg maker
Go to the top of the page
 
+Quote Post
   
Zeriab
post Aug 26 2009, 05:09 AM
Post #8


Level 12
Group Icon

Group: Revolutionary
Posts: 196
Type: Event Designer
RM Skill: Skilled




There are more implications than just allowing Vista users to save if the game is placed in the Program Files.
Let's say you delete the game and install it again, or install it in another place. The save files will still be there.
It also makes the importation of episodic games easier since you can easily locate saves from the previous game.

The downside is that the Application Data folder is hidden by default in Vista. There can also be some permission problems.
It does not work well if you have games on an USB stick so you can play the game on arbitrary computers.

*hugs*


__________________________
Go to the top of the page
 
+Quote Post
   
amaranth
post Aug 31 2009, 03:51 PM
Post #9


Level 6
Group Icon

Group: Member
Posts: 78
Type: Developer
RM Skill: Masterful




Hey Zeriab, the reason we created an environmental variable is because rpg maker games crash when you save to the %appdata% folder and your profile has a non-English character in it (like ABIGAƍL). The only way around this problem that we could find was to create a variable that generated the short version of the profile name. Does this make sense?

By default, most games today store their data in the %appdata% folder, so this is usually the safest place to put it. It's the standard that all of the game portals seem to require as well.

If you have a way to avoid creating a new environmental variable can you let me know? I can update this as needed and add you to the credits.

smile.gif

This post has been edited by amaranth: Aug 31 2009, 03:52 PM


__________________________
Go to the top of the page
 
+Quote Post
   
Zeriab
post Sep 1 2009, 11:15 AM
Post #10


Level 12
Group Icon

Group: Revolutionary
Posts: 196
Type: Event Designer
RM Skill: Skilled




Hey Amanda happy.gif
I never considered the problems of non-English characters.
I got no crashing when I tested it, but I found that FileTest could not detect files in there. Removing the checks I had no problems loading (and saving) the files.
I'm not really sure what to do about it, but I will definitely let you know if I find another way. (Unless it's very unsafe)

It's true that many games store their data in that folder. A couple store it in My Documents.
I think you can be right in that folder usually being the safest place, but not always. The only danger of having an opt-in feature of an alternate save location is the increase in complexity of the save system. Considering that the small size makes transportation on USB stick and etc feasible I would argue the gain is higher than the potential risk. You will be servicing the users more.

*hugs*
- Zeriab


__________________________
Go to the top of the page
 
+Quote Post
   
amaranth
post Feb 1 2010, 11:36 AM
Post #11


Level 6
Group Icon

Group: Member
Posts: 78
Type: Developer
RM Skill: Masterful




There were some bugs in the save code. I've fixed them. I've also attached a demo to this thread so you can see how it works.


__________________________
Go to the top of the page
 
+Quote Post
   
ZeroManArmy
post Feb 1 2010, 02:42 PM
Post #12


Level 5
Group Icon

Group: Member
Posts: 68
Type: Artist
RM Skill: Undisclosed




Screen shots?


__________________________
Go to the top of the page
 
+Quote Post
   

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 18th May 2013 - 02:18 PM
RPG RPG Revolution is an Privacy Policy and Legal
eXTReMe Tracker