Game Development Community

File writing updated bug 1.6

by Isaac Barbosa · in Torque Game Builder · 01/03/2008 (11:51 am) · 8 replies

Hello,

I know I have post another thread referencing this topic, but I feel the need of update the question in a new thread.

NOTICE:: THIS IS DRIVEN ME CRAZY AFTER LOTS of UNSUCCESSFUL TRYS

I'm trying to keep my game data saved using the same code I was using in 1.5 and it is not working (nothing is being saved using save().

I use this lines:

GameData.save(expandFilename("~/data/savedInfo/gameData.cs"));
exec("~/data/savedInfo/GameData.cs");

the exed path is this:

Quote:Executing C:/Users/Isaac/AppData/Roaming/2 Big Games/Lost Word Temple/game/data/savedInfo/GameData.cs

I'm using VISTA. But I can't understand why is this not working and why the path is not MyGames/Mygame/game/data/savedInfo/GameData.cs

Please help me to fix this!!!

Thanks!!!!!

#1
01/03/2008 (1:04 pm)
The reason that the save game information will be saved to the roaming folder is because Vista only allows files to be written in certain places by default. I imagine that your MyGames folder is located somewhere on your C drive (or equivalent) which, unless you have changed write permissions, is a restricted folder and cannot be modified without permission. This is why data will be written to the roaming folder, so that the file is saved, just in a different location.

What you should try is:
%fileName = expandFilename("~/data/savedInfo/gameData.cs");
GameData.save(%fileName);
exec(%fileName);

In the above, you will store the full location of the save game file, and therefore be able to execute it.

If I echo expandFilename("~/data/savedInfo/gameData.cs"), it references my game directory and not my roaming folder, this is because I am able to write to my game directory.

Vista's security is there for a reason, it may be annoying not to be able to save your saved games in the installation directory, but it is better than forcing all of your users to change their security settings.
#2
01/03/2008 (2:29 pm)
Thanks Phillip,

myGames folder is in Documents, the weird thing is that it has not restrictions to be written (there was no problem with this using 1.5) but something happen after TGB updated to 1.6

It is still echoing the wrong path and not writing where I want to do :(

But it is reading from the right folder:

exec("~/data/savedInfo/PlayerOneProfile.cs");
#3
01/08/2008 (1:04 pm)
Do you have an old version of the profile in the "MyGames/Mygame/game/data/savedInfo/PlayerOneProfile.cs" location? If so, deleting it may help.

What's happening with TGB 1.6 is that reading and writing are asymmetrical. TGB 1.6 will only write to your "user data" folder (C:\Users\User\AppData\Roaming\ on Vista), but it will read from either that folder or your game's folder.

Which location it tries reading first depends on the method used. Exec checks your game folder first, whereas opening a file for reading checks the user data folder first. So if you want to exec a file from the user data folder, you need to make sure a file with that name doesn't exist in the game folder.

Expanding the path probably won't make a difference, because TGB always uses relative paths now - supposed to make the process seamless, but if you had things set up the 1.5 way they'll need changing.
#4
01/08/2008 (5:03 pm)
Isaac, have you tried using:

expandFileName("^game/data/savedInfo/PlayerOneProfile.cs");

This also works for me.
#5
01/09/2008 (3:17 am)
It doesn't work either.

I, too, need TGB1.6 to write in the original game folder, as I have self writing code in the development version of my project (off course not in the compiled one) I need to have access to it.
#6
01/09/2008 (7:47 am)
@ Kalle,

I have fresh files but TGB keeps saving only in the users directory, not in the game directory :(

@ Phillip,

It doest'n works :(

I will try this later on windows xp to see if the problem persists

Thanks to both of you

@ Heaven,

*amn!
#7
01/09/2008 (12:07 pm)
Mmmmm, the problem that I have is that all of these things work while in the editor, but as soon as the game is run, they do not expand the locations properly.
#8
01/10/2008 (2:33 pm)
GG team,

Please let us know if this can be fixed and how.

I have tried Vista and XP and the problem persists in both platforms.