Ways for INIs to save multiple game files?
Hi, can someone tell me how to use the INI object to save multiple game files? Like the user can name their game file and it will save global values into that file, that way multiple people could have save files. Also is there a way to load multiple game files? Thanks.
Re: Ways for INIs to save multiple game files?
Just set the ini file to be the same as the player name!
So have an edit box, and when they click 'save' save an ini file which is called [contents of edit box].ini!
Re: Ways for INIs to save multiple game files?
Right.... I've used a technique like that before, guess it never really registered.:S Any ideas of how to load different files?
Re: Ways for INIs to save multiple game files?
Store the filenames in a list, then just loop through the list to get the filenames.
Re: Ways for INIs to save multiple game files?
I think I'm going to use a list object to display names, is there a way for MMF2 to check all of the INI files saved and put their filename in one line on the list, and then have it so that whichever line is selected when you click a button it will load that specific data? I know there's something simple I'm missing here, I know how to save one file and load it back but I've never really done multiple files. Thanks.
Re: Ways for INIs to save multiple game files?
The technique for loading one of multiple files is virtually the same, but you need to specify the file name to load in a different way - rather than just saying to set the INI object's file literally to "save.ini", you need to set it to the contents of the selected line of your list box - something like List Select$("List").
I think that the List object even has a "Load file list" action so that you can instantly get a list of INI files in your game's folder.
Re: Ways for INIs to save multiple game files?
I always use Tree Control Object to display all of the INI files in the folder. Then player can choose a file, which he wants to load.
Re: Ways for INIs to save multiple game files?
Thanks for that last bit of info, the whole saving and loading a list worked perfectly. Here, I'll list what I have so far. On my title frame, you can select New game or load. When you press new game, you can type in a name, which is saved to the list object. The ini's current file is set to the contents of the edit box then. So now you play the game, and some global values get set to the ini. Then, when you come back, this time you choose load and your name is on the list object. You click it and press start, but when you go back to the game your global values aren't set. And another thing, is it possible to set the ini's path to your game's folder without saving it as the name? I did my path into a folder called "Game data" but when I actually went there it was saved outside the folder and titled "Game data.ini". If I could just set it's path but still make the user able to set it's name I think everything would work. Thanks.
Re: Ways for INIs to save multiple game files?
Code:
Set current file to
Apppath$+"your_folder\"+text from Edit Object
Apppath$ takes a full path to your game. Then you can add folder, which in you want to save your files and finally add the filename from the Edit Box.
Result will be for example:
C:\Your game\Saves\my_file.ini
C:\Your game\ = Apppath$
Saves\ = name of the folder with save files
my_file.ini = filename taken from the Edit Box
Re: Ways for INIs to save multiple game files?
Thanks... I tried it but only found that it wasn't saving the ini anywhere. The path to my game folder is C:\Program Files\Game Title. Now I have another folder in the game title folder that holds save data. So here's what I put whenever the user either types a new name or loads a saved game:
Set current file to
Apppath$+"Game Title"+Edittext$("Edit Box")
Of course with the "Game Title" name being my game folder. First I just want to see if it will at least save the ini into the game folder, then try the game data folder within the game folder. Is there something I'm doing wrong with the code or is there another way? Thanks.