- Joined
- May 11, 2018
- Messages
- 4
- Reaction score
- 0
- First Language
- English
- Primarily Uses
- RMXP
A friend and I are working on our own games and would like to add bonus content to our games if the player has save data of the other game on their computer. but the "user name" folder seems to be an issues while checking for a save file.
FileTest.exist?("C:\\users\*name*\Saved Games\Game\Game.rxdata")
Can anyone help me with this?
Edit:
While trying to find an answer for this I found a function called "dir.children()" or "dir.each_child()" which checks each entry for that directory. So I think I need to change the directory with Dir.chdir("C:\\users") then follow up with Dir.each_child("Saved Games\") and finally check for the actual file. FileTest.exist?("Game\Game.rxdata")
It is going to be a little bit before I can test this, if anyone figures this out please let me know.
Edit2: Still try to work this out, but the script has changed a little.
FileTest.exist?("C:\\users/"+"*name*"+"Saved Games/Name_of_Game/Game.rxdata")
Final Edit:
I have figured it out, apparently I was looking for an "environment" which is the root directory of a user account, for anyone using Windows 7 or newer this should be what you are looking for if you which to do the same.
if FileTest.exist?("#{ENV['HOMEPATH']}\\Saved Games/NameOfGameHere/Game.rxdata") == true
(do a thing here)
else
(don't do a thing or do a different thing)
end
Can anyone help me with this?
Edit:
While trying to find an answer for this I found a function called "dir.children()" or "dir.each_child()" which checks each entry for that directory. So I think I need to change the directory with Dir.chdir("C:\\users") then follow up with Dir.each_child("Saved Games\") and finally check for the actual file. FileTest.exist?("Game\Game.rxdata")
It is going to be a little bit before I can test this, if anyone figures this out please let me know.
Edit2: Still try to work this out, but the script has changed a little.
FileTest.exist?("C:\\users/"+"*name*"+"Saved Games/Name_of_Game/Game.rxdata")
Final Edit:
I have figured it out, apparently I was looking for an "environment" which is the root directory of a user account, for anyone using Windows 7 or newer this should be what you are looking for if you which to do the same.
if FileTest.exist?("#{ENV['HOMEPATH']}\\Saved Games/NameOfGameHere/Game.rxdata") == true
(do a thing here)
else
(don't do a thing or do a different thing)
end
Last edited:


