Export function not writing in tGB 1.5.1
by Stanley D Chatman · in Torque Game Builder · 07/29/2007 (10:29 am) · 7 replies
I am trying to write out to a prefs file but it seems all directories are write protected I have tried many variations and all give same error message:
Unable to open file 'C:/Documents and Settings/schatman.GOLDENDOODLE/Application Data/Independent/SmashEmoticons/game_vars.cs for writing.
export("$game_vars::*", "game_vars.cs");
I have played with getUserDataDirectory();
I have played with getPrefsPath();
I have rolled my own version
My question how are we suppose to write out our game prefs files. How do we find a writable driectory.
Unable to open file 'C:/Documents and Settings/schatman.GOLDENDOODLE/Application Data/Independent/SmashEmoticons/game_vars.cs for writing.
export("$game_vars::*", "game_vars.cs");
I have played with getUserDataDirectory();
I have played with getPrefsPath();
I have rolled my own version
function getWriteablePath()
{
%modpath = findfirstfile("*/game/main.cs");
if(isFile(%modpath))
$mymodpath = filePath(%modpath);
else
{
%modpath = findFirstFile("*/game/main.cs.dso");
$mymodpath= filePath(%modpath);
}
return $mymodpath;
}
$PREFS_PATH = getWriteablePath() @ "/prefs/game_vars.cs";My question how are we suppose to write out our game prefs files. How do we find a writable driectory.
#2
Nice trick by the way..
Now nothing works for me..
Unable to open file 'C:/Documents and Settings/schatman.GOLDENDOODLE/Application Data/Independent/SmashEmoticons/C:/Documents and Settings/schatman.GOLDENDOODLE/My Documents/MyGames/SmashEmoticons/game/prefs/game_vars.cs for writing.
07/29/2007 (1:31 pm)
Thing is even your trick does not work anymore in TGB 1.5.1!! Your trick worked in TGB 1.5 but now since export uses relative paths, it appears to append a getPrefsPath() call. I don't have pro so I can't validate but the export is using getPrefPath().Nice trick by the way..
Now nothing works for me..
Unable to open file 'C:/Documents and Settings/schatman.GOLDENDOODLE/Application Data/Independent/SmashEmoticons/C:/Documents and Settings/schatman.GOLDENDOODLE/My Documents/MyGames/SmashEmoticons/game/prefs/game_vars.cs for writing.
#3
The big question here, is : why ?
(Stanley, if you want it to work asap, you'll have to replace the global $game_vars:: by a scriptobject and use the save function instead of export)
07/29/2007 (4:20 pm)
Ah, indeed, I just tested, export is changed in 1.5 and doesn't work anymore. The big question here, is : why ?
(Stanley, if you want it to work asap, you'll have to replace the global $game_vars:: by a scriptobject and use the save function instead of export)
#4
They really need to get the whole File I/O cleaned up in TGB 1.5 and get a stable release available.
07/30/2007 (11:20 am)
Thanks for the tip about scriptobject, but I have been using export all over the place and do not want to re-design or re-write that particular codebase.They really need to get the whole File I/O cleaned up in TGB 1.5 and get a stable release available.
#5
08/16/2007 (10:24 pm)
Anybody found a way to get export to work again? That doesn't involve recompiling the engine?
#6
08/17/2007 (9:06 am)
Quote:Anybody found a way to get export to work again? That doesn't involve recompiling the engine?Hum, by using 1.5.0 instead of 1.5.1 ^^'
#7
08/18/2007 (3:11 am)
Thanks for the reporting and confirmation... this has been noted :)
Torque Owner DragonSix
Happily you found my trick to be able to write ^^ you'll have to keep using it until next patch.