Cannot Save Settings
by Jeremy Alessi · in Torque Game Builder · 08/15/2007 (6:03 pm) · 43 replies
I'm not quite sure what's happened to the old prefs system in TGB but now there's the commonConfig.xml file which saves a few settings. Unfortunately that file won't write for me.
This is coming up in my console. I've searched this entire site but nothing seems to be coming up for saveGameConfigurationData ... as far as bugs go.
XML::beginWrite - Failed to write to file common/commonConfig.xml. saveGameConfigurationData - Failed to write to file: common/commonConfig.xml
This is coming up in my console. I've searched this entire site but nothing seems to be coming up for saveGameConfigurationData ... as far as bugs go.
#2
08/17/2007 (7:22 am)
Any luck/workaround with this one, Jeremy? We're trying to do the same thing...
#3
Add/change these in your "/game/main.cs"
Then ...
Replace these lines in the "/common/main.cs" script file
08/17/2007 (10:34 am)
Sure, here it is:Add/change these in your "/game/main.cs"
function loadPath( %path )
{
setMyGamesModPaths( getMyGamesModPaths() @ ";" @ %path );
exec(%path @ "/main.cs");
}
function setMyGamesModPaths()
{
// Another way to get the mod path by searching it
%modPath = findfirstfile("*/game/main.cs");
if(isFile(%modPath))
$myModPath = filePath(%modPath) @ "/";
else
{
%modPath = findFirstFile("*/game/main.cs.dso");
$myModPath= filePath(%modPath) @ "/";
}
}
function getMyGamesModPaths()
{
return $myModPath;
}Then ...
Replace these lines in the "/common/main.cs" script file
//_loadGameConfigurationData( expandFileName("./commonConfig.xml") ); //Original
_loadGameConfigurationData( getMyGamesModPaths() @ "commonConfig.xml" );
//_saveGameConfigurationData( expandFileName( "./commonConfig.xml") ); //Original
_saveGameConfigurationData( getMyGamesModPaths() @ "commonConfig.xml" );
#4
09/20/2007 (3:07 pm)
Jeremy, one point of clarification: the first block of code goes in the game/main.cs, not in the common/main.cs, right?
#5
09/20/2007 (3:40 pm)
Yes, that's what I did. You could also save the settings in the common folder if you wanted too.
#6
I've tried this unsuccessfully. Is there a trick?
I just have copied and pasted both code blocks. Any renaming convention with getMyGamesModPath or some specific name path with my game name such $myModPath= filePath(%modPath) @ "/";?
09/26/2007 (3:26 pm)
Hi,I've tried this unsuccessfully. Is there a trick?
I just have copied and pasted both code blocks. Any renaming convention with getMyGamesModPath or some specific name path with my game name such $myModPath= filePath(%modPath) @ "/";?
#7
I always use expandFilename before using the filesystem, so it was easy for me to do a find and replace across my scripts to substitute this temporary function. When the fixed update is out, I will just find/replace back.
Greg
09/29/2007 (2:09 pm)
Here is the function I use in my game.cs file:function expandFilenameFix(%thePath) {
%prePath = findfirstfile("*/game/main.cs");
%thePath = stripChars(%thePath,"~");
%thePath = filePath(%prePath) @ %thePath;
}I always use expandFilename before using the filesystem, so it was easy for me to do a find and replace across my scripts to substitute this temporary function. When the fixed update is out, I will just find/replace back.
Greg
#8
If this site had stickies, this should be a sticky. Thanks agian!
10/30/2007 (9:37 pm)
Thanks! I spent around 2 hours trying to figure out why my XML file was not getting saved. beginWrite was failing. I was able to read it just fine. Once I finally realized the GG code for _saveGameConfigurationData was not even saving my the commonConfig.xml file, I knew something was up. Suddenly I recalled having heard about a File I/O issue so I did a search.If this site had stickies, this should be a sticky. Thanks agian!
#9
I am confused by one thing. You suggest a change to common/main.cs that references a function in game/main.cs. When I look at the console log I see that common/main.cs is loaded before game/main.cs. Are the scripts not being executed at that point? Otherwise, how can a function in common/main.cs reference a function that has not yet been loaded?
10/31/2007 (6:14 am)
Jeremy,I am confused by one thing. You suggest a change to common/main.cs that references a function in game/main.cs. When I look at the console log I see that common/main.cs is loaded before game/main.cs. Are the scripts not being executed at that point? Otherwise, how can a function in common/main.cs reference a function that has not yet been loaded?
#10
10/31/2007 (8:07 am)
In your console you see the scripts being compiled but the function itself isn't called at that point. Once the game actually compiles all the scripts then it begins true function level execution.
#11
10/31/2007 (8:08 am)
Thank you Jeremy for the explanation.
#12
There is a typo in your code for "/common/main.cs".
Your code has getMyGamesModPath() but the function is named getMyGamesModPaths()
10/31/2007 (8:25 am)
Jeremy,There is a typo in your code for "/common/main.cs".
Your code has getMyGamesModPath() but the function is named getMyGamesModPaths()
#13
10/31/2007 (8:55 am)
Good call! My game actually uses different names so I typed those seperately ;0
#14
I have tried both your suggestions without success. commonConfig.xml is not updated and an error is thrown.
10/31/2007 (5:48 pm)
Tetraweb, Jeremy,I have tried both your suggestions without success. commonConfig.xml is not updated and an error is thrown.
#15
10/31/2007 (6:30 pm)
CommonConfig inside the game directory and not the common directory? What is the error? I honestly got this working a while ago. I might have had to do a few things different from this thread but now it's in the blurry past.
#16
Part 1: To fix the file search issue described above, look at the "onExit()" function in the common/main.cs file. I just replace this line:
_saveGameConfigurationData( expandFileName("./commonConfig.xml") );
with this line:
_saveGameConfigurationData (findFirstFile("*/commonConfig.xml"));
Part 2: My global screen resolution variable "$Game::Resolution" is not being updated at the time I'm saving the common configs. I added this line in the beginning of the "_saveGameConfigurationData()" function in the "common\gameScripts\properties.cs" file:
echo("resolution ["@ $Game::Resolution @"]");
Sure enough, this value was not updated via the GUI interface.
I gotta run off to some meetings now, but I'll update the thread when I find out more.
11/02/2007 (1:36 pm)
I'm having a similar issue but it's a 2 part problem.Part 1: To fix the file search issue described above, look at the "onExit()" function in the common/main.cs file. I just replace this line:
_saveGameConfigurationData( expandFileName("./commonConfig.xml") );
with this line:
_saveGameConfigurationData (findFirstFile("*/commonConfig.xml"));
Part 2: My global screen resolution variable "$Game::Resolution" is not being updated at the time I'm saving the common configs. I added this line in the beginning of the "_saveGameConfigurationData()" function in the "common\gameScripts\properties.cs" file:
echo("resolution ["@ $Game::Resolution @"]");
Sure enough, this value was not updated via the GUI interface.
I gotta run off to some meetings now, but I'll update the thread when I find out more.
#17
11/02/2007 (2:06 pm)
I added two new variables for the resolution and I also had to make a fix to save the full screen flag. That was something I neglected to mention here. However, those had nothing to do with the actual file being written. They were just oversights elsewhere in the code.
#18
When I shutdown my game, the following is in the console.log:
XML::beginWrite - Failed to write to filecommon/commonConfig.xml.
saveGameConfigurationData - Failed to write to file: common/commonConfig.xml
The question I have is, isn't the problem with writing to the file and not a problem with finding the file to write to? Even without making any changes to 1.5.1, file is being found and read in without any modifications needed. I don't see how simply changing the path/filename will make any difference.
At this point I am going to sit tight and wait for the next patch to TGB. This must be a priority bug for the developers to fix. I can't see it not being fixed.
Thanks for you help.
11/04/2007 (4:25 am)
Jeremy,When I shutdown my game, the following is in the console.log:
XML::beginWrite - Failed to write to filecommon/commonConfig.xml.
saveGameConfigurationData - Failed to write to file: common/commonConfig.xml
The question I have is, isn't the problem with writing to the file and not a problem with finding the file to write to? Even without making any changes to 1.5.1, file is being found and read in without any modifications needed. I don't see how simply changing the path/filename will make any difference.
At this point I am going to sit tight and wait for the next patch to TGB. This must be a priority bug for the developers to fix. I can't see it not being fixed.
Thanks for you help.
#19
Something you wrote got me thinking: "CommonConfig inside the game directory and not the common directory?"
I don't have a commonConfig.xml file in my games directory, only in my common directory. When I use Torsion and look at what is being read in [common/gamescripts/properties(39)], it is loading common/commonConfig.xml.
So, if your code and Tetraweb's code is writing to the game directory, then when does it load games/commonConfig.xml? Or are you modifying properties.cs as well, so it loads from the game directory?
11/04/2007 (5:01 am)
Jeremy,Something you wrote got me thinking: "CommonConfig inside the game directory and not the common directory?"
I don't have a commonConfig.xml file in my games directory, only in my common directory. When I use Torsion and look at what is being read in [common/gamescripts/properties(39)], it is loading common/commonConfig.xml.
So, if your code and Tetraweb's code is writing to the game directory, then when does it load games/commonConfig.xml? Or are you modifying properties.cs as well, so it loads from the game directory?
#20
11/04/2007 (12:45 pm)
Yeah mine is loading from the game directory because that's what I wanted to do. The code above looks for the file in the game directory to get the path.
Torque Owner Jeremy Alessi