TailsSena Posted September 23, 2011 Report Share Posted September 23, 2011 How do I check to see if the player has a) played the game before; or has a save file which can be loaded. As of now it tries to load a save file that may or may not be there... It loads the array form the application directory, with no filename specified, so I highly doupt I'm doing this right... Link to comment Share on other sites More sharing options...
Bosco Posted September 23, 2011 Report Share Posted September 23, 2011 Are you using the .ini extension? Link to comment Share on other sites More sharing options...
GSF Posted September 23, 2011 Report Share Posted September 23, 2011 To check the first one, simply make a global "config" save file (it can be an ini) and leave a value there as 0. When the game starts, check if said value is 0, and if it is, do whatever you need to do, while setting said value to 1. You can use this ini to store stuff such as default controls, window size, among other things. ------------------- To do the second check, there are various methods. I'm assuming you're loading a "fixed" array (ergo, one with a specific name that won't change). This array should always exist (include it in your default installation). You can use the File object to check if it exists. If it doesn't, immediately write the array to file so it's recreated. You'll have to compare the first "free" byte of your array (remember that MMF arrays begin with CNC ARRAY as ASCII text), if it's equal to zero. +Condition ---*Action +[color=#0000CC]ValAtXYZ[/color]([color=#00AA00]"Array"[/color],[color=#CC0000]0[/color],[color=#CC0000]0[/color],[color=#CC0000]0[/color]) = [color=#CC0000]0[/color] ---*actions here Assuming your value array is zero-based, this event will compare the first usable value of the array to zero. There, you can do as you wish. If you use a text array instead, simply replace ValAtXYZ with StrAtXYZ and the 0 in the second expression with "". 1 Link to comment Share on other sites More sharing options...
TailsSena Posted September 24, 2011 Author Report Share Posted September 24, 2011 @Gsoft: How do I check for the files existance with the File object though? Can't find the command. I can handle it from there. (I think) Link to comment Share on other sites More sharing options...
GSF Posted September 24, 2011 Report Share Posted September 24, 2011 Easy: The File object has a pair of conditions "File is Readable" and "File is Writable". Either of these will work. When it asks for an expression, use appdir$ as an equivalent for the application directory. Example: appdir$+"\Music\boss.mp3" would point to the file "boss.mp3" inside a "Music" directory, which is in the directory where the application's executable resides. Link to comment Share on other sites More sharing options...
TailsSena Posted September 24, 2011 Author Report Share Posted September 24, 2011 Works completely now, thanks! There's even a file "Save.ini" in my test build directory. Link to comment Share on other sites More sharing options...
Recommended Posts