FileIO--path for file in exec?
by Laralyn McWilliams · in Torque Game Builder · 04/10/2010 (4:08 pm) · 5 replies
I'm doing the fileIO tutorial and like other folks who posted, I can't find the file even though I get the success message when I execute the writeFile() function.
I've read through all the other posts and I checked everywhere for test.txt. I don't have the directory Application DataIndependentUntitledGamegamegameScriptsgamedata. I checked every folder in AppData for my username and for Default and Public. I made sure hidden files are being displayed. Could the file be stored somewhere else on Windows 7?
Thanks!
I've read through all the other posts and I checked everywhere for test.txt. I don't have the directory Application DataIndependentUntitledGamegamegameScriptsgamedata. I checked every folder in AppData for my username and for Default and Public. I made sure hidden files are being displayed. Could the file be stored somewhere else on Windows 7?
Thanks!
#2
You should use the same directory for a saved file and a loaded file. From your point of view, it shouldn't matter. If you save to "game/data/saveFile.sav", you'll want to exec "game/data/saveFile.sav".
04/11/2010 (4:05 pm)
This has been answered twice in the last week. There are standards for file locations introduced in Windows Vista. If you need to modify files in the install directory, the user has to run your game in administrator mode, which is bad. Therefore, all data is put in the %APPDATA% directory (which varies in XP, Vista, and 7).You should use the same directory for a saved file and a loaded file. From your point of view, it shouldn't matter. If you save to "game/data/saveFile.sav", you'll want to exec "game/data/saveFile.sav".
#3
exec("./fileIO.cs"); (in dev path, in gameScripts)
exec("./saves/test.cs"); (in %APPDATA%, in a subfolder of gameScripts)
04/11/2010 (4:53 pm)
I understood the locations, but what I wasn't getting is that you use the exact same path for the exec as you do for the save/load. Because the save file isn't in the development path with the other game scripts, I figured I had to somehow indicate that in the paths. TGB seems to sort out on its own that the files in these commands are actually in two different paths on the hard drive (I assume by searching both paths):exec("./fileIO.cs"); (in dev path, in gameScripts)
exec("./saves/test.cs"); (in %APPDATA%, in a subfolder of gameScripts)
#4
04/11/2010 (5:18 pm)
Yep, you got it! Also, not only will it check both locations, but it'll automatically create the directories it needs.
#5
06/06/2010 (10:41 am)
Edit--posted to the wrong thread!
Torque Owner Laralyn McWilliams
If I want to write my save file with script and then simply exec it, what is the path I would use for the exec command? The TDN article says that TGB searches the AppData directory, but when I exec like this, I get an error that it can't find the file:
exec("./save.sav");
It also can't find the file if I use:
exec("./eluminarts/SCards/game/gameScripts/save.sav");