Display $SAVEGAMEDIR$...string formatting question **ABANDONNED**

Started by Knox, Mon 10/01/2011 22:10:59

Previous topic - Next topic

Knox

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 ), 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):

Code: ags
    
                                      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);
--All that is necessary for evil to triumph is for good men to do nothing.

Gilbert

I don't think it is possible to do this at the moment.

Khris

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.

Knox

ahh crap, ok so nothing can be done then to get that path as a string inside a Display.

Okee...
--All that is necessary for evil to triumph is for good men to do nothing.

monkey0506

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.

Knox

Ok so something like
Code: ags
 String sPath = Game.SetSaveGameDirectory("thepath");


My game-saves get placed automatically into:
Code: ags
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):

Code: ags
 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...
--All that is necessary for evil to triumph is for good men to do nothing.

Khris

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):
Code: ags
  Game.SetSaveGameDirectory("saves");
  SaveLocation = "\"saves\" inside your game folder.";


or:
Code: ags
  Game.SetSaveGameDirectory("$MYDOCS$/Gamename saves");
  SaveLocation = "\"Gamename saves\" inside your My Documents folder.";


To show the player where they can find the savegames, call
Code: ags
  Display("Your savegames are in a folder called %s", SaveLocation);


In theory it should be possible to call
Code: ags
  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.

Knox

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)
--All that is necessary for evil to triumph is for good men to do nothing.

SMF spam blocked by CleanTalk