I think this is going to be another easy one, I checked String Formatting in the manual + $SAVEGAMEDIR$ search in the forums without luck.
From a previous question (http://www.adventuregamestudio.co.uk/yabb/index.php?topic=41294.0 (http://www.adventuregamestudio.co.uk/yabb/index.php?topic=41294.0)), I was able to query if a certain file existed, but how do I get Display to print out the actual save-game path as a variable? I tried these two lines without luck (I can't seem to be able to convert $SAVEGAMEDIR$ into a string variable):
input = txtScreenshotInput.Text;
input = input.Append(".bmp");
Solution A (failed): String sPath = "$SAVEGAMEDIR$";
Display("Screenshot saved to: %s/%s", sPath, input);
Solution B (failed): Display("Screenshot saved to: %s/%s", $SAVEGAMEDIR$, input);
I don't think it is possible to do this at the moment.
I guess with the handful of commands that support $SAVEGAMEDIR$, the supplied string is searched for that tag and then the tag gets replaced with the actual path. It's not a global constant.
ahh crap, ok so nothing can be done then to get that path as a string inside a Display.
Okee...
Well presumably if it were supported there would be something like Game.GetSaveGameDirectory, to match Game.SetSaveGameDirectory..but for now the best way to try and get it in a String is to store it in a variable yourself and only set it from the script.
Ok so something like
String sPath = Game.SetSaveGameDirectory("thepath");
My game-saves get placed automatically into:
C:\Users\*username*\Saved Games\*gamename*
Im guessing depending on the user's OS this location will be different? So by using the "Game.SetSaveGameDirectory" I can force the savegames to be placed there instead...I guess I need to do something like (pseudo code):
String sPath = Game.SetSaveGameDirectory("if it exists c:/Users + the system user name + saved games if it exists + game name");
If those folders dont exist, then create them, etc...
No, first of all the first line will throw an error since the command returns a bool.
Also, it might be "C:\Users" on your computer, on mine it's "C:\Dokumente und Einstellungen" and "V:\Users", depending on whether I boot XP or 7.
Then there's no way to check for the existence of a directory outside the game dir, let alone to get the User's user name.
All you can do is ask the user if they want the savegames in the game's folder or in "My Documents".
Depending on the choice you call (SaveLocation is a global string you have to declare):
Game.SetSaveGameDirectory("saves");
SaveLocation = "\"saves\" inside your game folder.";
or:
Game.SetSaveGameDirectory("$MYDOCS$/Gamename saves");
SaveLocation = "\"Gamename saves\" inside your My Documents folder.";
To show the player where they can find the savegames, call
Display("Your savegames are in a folder called %s", SaveLocation);
In theory it should be possible to call
Game.SetSaveGameDirectory(".");
A period in a path points to the current folder, so the savegames should end up directly in the game folder.
All of this is a really bad idea and I wouldn't recommend using the command in general.
For instance AGS will create the 999 savegame automatically as soon as you start the game (all that RestartGame() does is load that savegame), so if you change the savegame location mid-game, you lose the ability to restart, at least during the current session or until you call SetRestartPoint(); Even if you do that though, a savegame.999 file will remain at the default location with all other savegames ending up elsewhere.
In short, it's probably best to keep the save games at the default location to ensure Vista compatibility and not change the location, ever.
hmm, ok, Ill take your advice and just let it be the way it is. I just really wanted a prompt to let the player know exactly where their save games are located, instead of putting that info in a manual or something (which most people never read). Ive got a script that takes screenshots + saves them to the same location, so for people taking screens, I wanted something like: Your screenshot "screen01.bmp" has been successfully saved to "c:\blah"...too bad the default folder $SAVEGAMEDIR$ cant be used.
Minor thing anyways, Ill live without it...(but Ill have nightmare-filled sleepness nights for 3 weeks)