Save()
by Dan Phillips · in Torque Game Builder · 07/14/2007 (9:42 am) · 31 replies
I can't get save to work. This code worked in 1.3 or whatever the last version of tgb was.
Also, what path should I be saving to that will work in vista and xp?
$saveGameDir = "~/data/files/";
new ScriptObject(settings) {};
settings.currentMusicLevel = $currentMusicLevel;
settings.currentSoundLevel = $currentSoundLevel;
settings.fullscreen = isFullscreen();
settings.save(expandFileName($saveGameDir @ "settings.cs"));I'm on vista, I also tried saving to the user directory, didn't work.Also, what path should I be saving to that will work in vista and xp?
#22
getPrefsPath() should be fixed in the newest version, 1.5.1.
@ Dan -
As for your .dso execing error, don't try to exec the .dso itself just the .cs. If a .cs file doesn't exist it will automatically exec the .dso.
07/27/2007 (1:19 am)
@ Tyler - getPrefsPath() should be fixed in the newest version, 1.5.1.
@ Dan -
As for your .dso execing error, don't try to exec the .dso itself just the .cs. If a .cs file doesn't exist it will automatically exec the .dso.
#23
SimObject.Save("game/data/save/test.sav");
I have already created the game/data/save folder.
08/07/2007 (6:55 pm)
I am also trying to use SimObject.Save() and it is always returning false and not saving regardless of what filename / path I try. Is the Project directory also not writable? Heres what I was trying to doSimObject.Save("game/data/save/test.sav");
I have already created the game/data/save folder.
#24
08/16/2007 (10:21 pm)
I'm trying to figure out how to save preferences using the export function... am I correct in understanding from this thread that I have to recompile the engine to do this?
#25
http://www.garagegames.com/mg/forums/result.thread.php?qt=66131
10/02/2007 (2:53 am)
Would someone please confirm that the method in this thread works for you or not?http://www.garagegames.com/mg/forums/result.thread.php?qt=66131
#26
Though our project is finished, it waits in dead-end street.
Saving ini or highscore table in game's directory is out of the question - "Program files" folder is read-only. "Application data" in user's profile isn't writable!!!??
Any idea what else can I do?
Can you, people from GarageGames tell your TGB Indie customers where they can save game data files
...
or at least when the fileIO fix for TGB will be available ????
---------------------------
Samo Novak
Esc2Games
11/01/2007 (3:36 pm)
Over 3 months passed since Luke & Adam Larson found solution for write access to user's "application data" folder. I own TGB indie, so everything stops for me at "#1 - you must have TGB Pro.".Though our project is finished, it waits in dead-end street.
Saving ini or highscore table in game's directory is out of the question - "Program files" folder is read-only. "Application data" in user's profile isn't writable!!!??
Any idea what else can I do?
Can you, people from GarageGames tell your TGB Indie customers where they can save game data files
...
or at least when the fileIO fix for TGB will be available ????
---------------------------
Samo Novak
Esc2Games
#28
For example: "C:\Documents and settings\steven\Application data\yourgame"
11/01/2007 (4:54 pm)
Steven, can you write anything to your user's profile "Application data" folder ?For example: "C:\Documents and settings\steven\Application data\yourgame"
#29
First I tried to write to the MyDocuments/NameOfYourGame directory. I did this:
That worked for both XP and Vista (even with UAC turned on).
Next, I tried the Application Data directory. I used the following code:
And that worked just fine.
Please let me know how it works for you.
11/01/2007 (6:35 pm)
I tested the code and it works. Keep in mind, I used Tetraweb's listed fix, not the original listed code.First I tried to write to the MyDocuments/NameOfYourGame directory. I did this:
if (%doodah.beginWrite(expandFilenameFix("~/../score.xml")))That worked for both XP and Vista (even with UAC turned on).
Next, I tried the Application Data directory. I used the following code:
if (%doodah.beginWrite(expandFilenameFix("~/../../../../Application Data/MyGame/score.xml")))And that worked just fine.
Please let me know how it works for you.
#30
The whole problem is how you specify the file path. It must be absolute path relative to game folder.
example:
// wrong !!!!
// %file = "c:/document and settings/user/application data/mygame/settings.ini";
// right
%file = "c:/tgb/games/mygame/game/../../../../application data/mygame/settings.ini";
addResPath ("c:/tgb/games/mygame/game/../../../../application data/mygame");
%inifile = new FileObject();
%inifile.openForWrite (%file);
...
...
Reading of file doesn't work without addResPath !!! I don't know why.
---
Steven S, thank you very much.
11/02/2007 (10:02 am)
Yes, it works! Your two examples above explain everything.The whole problem is how you specify the file path. It must be absolute path relative to game folder.
example:
// wrong !!!!
// %file = "c:/document and settings/user/application data/mygame/settings.ini";
// right
%file = "c:/tgb/games/mygame/game/../../../../application data/mygame/settings.ini";
addResPath ("c:/tgb/games/mygame/game/../../../../application data/mygame");
%inifile = new FileObject();
%inifile.openForWrite (%file);
...
...
Reading of file doesn't work without addResPath !!! I don't know why.
---
Steven S, thank you very much.
#31
Glad it works.
11/02/2007 (12:53 pm)
Ooops. Right. I should have clarified everything is based on the 'game' directory.Glad it works.
Torque Owner Tyler Lin
but I think I found the problem.
I got execPrefs() to work when i commented out the following code in Platform::getPrefsPath.
#ifdef TORQUE_PLAYER return StringTable->insert(file ? file : ""); #elseI believe getPrefsPath returned nothing and therefore "file not found"